I am trying to get a MC56F8037 to read a Quadrature encoder. It is difficult as the last embedded platform I programmed on an open loop V/Hz Induction motor speed control on a . . .9S12C . . . is different to the DSP architecture of the 56F8037 . I have 2 questions.
1. I tried writing the code to do the quadrature encoding by myself. But it did not work. Should I attempt to use the stationery code in processor expert? Like in this post? https://community.freescale.com/message/47553#47553 . Or does someone think that my code is close to working?
2. I have noticed that you cannot write to some registers in the 56F8037 using the assignment operator ' = ' in C. (I get an lvalue error). This is different from the 9S12 why is this so?. I believe in the code snippet provided I am using an assembly move instruction to write to the register, as this is how the examples in codewarrior worked. Is there a document aimed at HC12/9S12 programmers transitioning to the 56F8XXX type DSC's?
Here is the code, as best as I can currently interpret the Peripheral description and System Intergration Module documents.
/* DISABLE COP TIMER */
//initialise quadrature encoder
asm (move.w #$8020,XIM_GPSA0); //Bit 6=1 (Timer A0 ON GPIOA6) and Bit 12=1 (Timer A1 on GPIOA12)
asm (move.w #$1000,XIM_GPSA0); //Bit 12=1 (Timer A0)
asm (move.w #$0100,XIM_GPSA1); //Bits 9-8 = 10 (Timer A1)
asm (move.w #$0080,X:TMRA0_CTRL); //0x0080
asm (move.w #$0000,X:TMRA0_SCTRL); //0x0000
asm (move.w #$0000,X:TMRA0_CNTR); //0x0000
asm (move.w #$0000,X:TMRA0_LOAD); //0x0000
asm (move.w #$FFFF,X:TMRA0_COMP1); //0xFFFF
asm (move.w #$0000,X:TMRA0_COMP2); //0x0000
asm (move.w #$0000,X:TMRA0_CSCTRL); //0x0000
asm (move.w #$8080,X:TMRA0_CTRL); //0x8080
printf("Value of Quadrature Decoder:%u",TMRA0_CNTR); //very large function will not be present after debugging
Im expecting inputs are on Pins A6 and A12. And the count value appears in TMRA0_CNTR up or down counting depending on direction.
Thanks for a reply in advance.