|
|
|
|
|
Freescale Forums :
CodeWarrior :
8- & 16-bit :
problems with TPMC0V
|
|
|
|
|

|
problems with TPMC0V
|
|
Danielito
Contributor
Posts: 13
Registered: 2008-02-28

Message 1 of 7

Viewed 112 times
|

|
|
I have problems with TPMC0V in 9S08QG8: 1)If I do the following: TPMC0V & = 0x0000; TPMC0V = 0x001C * b_two - 0x5455B; / * Valor toma TPMC0V la CE. Lineal * / TPMC0V not deleted But if I do following: while(TPMC0V != 0) { TPMC0V&=0x0000; /*borro TPMC0V*/ } TPMC0V=0x001C * b_two - 0x5455B TPMC0V clears ???????? 2) If I do: TPMC0V=0x001C * b_two - 0x5455B;/*TPMC0V toma valor de ec. lineal*/ b_three=TPMC0V;/*visualizo el BLS de TPMC0V*/ b_three takes no values TPMC0V and I have not view????? What can I do? Any suggestion is welcome Thank Danielito
|
|
|
|
2009-11-05 03:26 PM
|
|
|
|

|
Re: problems with TPMC0V
|
|
jag
Trusted Contributor
Posts: 79
Registered: 2006-09-14

Message 2 of 7

Viewed 95 times
|

|
|
Hi, first: when posting code, please translate comment or whatever in english: not all the people here speak spanish. This: TPMC0V & = 0x0000; what it should do? It's not better to simply write: TPMC0V = 0; ? are you sure that this: 0x001C * b_two - 0x5455B gives you what you really want? 0x5a55B is more than 16bit. Try to put a variable in the middle: temp = 0x001C * .... TPMC0V = temp; and check with the debugger what is temp. Btw if you do something like this: TPMC0V = 0; TPMC0V = 12; the compiler will delete the first instruction because is useless. I'm not sure I've answered your questions because I'm not sure I understood what the questions are. Bye Jack
|
|
|
|
2009-11-06 12:45 PM
|
|
|
|

|
Re: problems with TPMC0V
[ Edited ]
|
|
Danielito
Contributor
Posts: 13
Registered: 2008-02-28

Message 3 of 7

Viewed 90 times
|

|
|
Jack: 1) thanks for the utmost account. 2) the idea is to drive a led by PWM. The datos isgoin a MCU for a program terminal V1.9. It controls the duty cycle byTPMC0V.The problem is when I clear TPMC0V, P.E. TPMC0V=0 orTPMC0V&=0X0000,this register not clear, but if I do the following: while(TPMC0V!=0) { TPMC0V=0; } this register clear???? How do I know? For example: if I write in thefile MCUinit.c of my program PWM4.mcp: TPMC0V=0x0000; /**/ TPMC0V=0x001C * b_two - 0x5455B;/*TPMC0V takes values from linearequation */ and then write streams in the program terminal V1.9: e1e1e5e5e9e9 (loadbuffer) and then ll followed by "enter" (read buffer and loadedTPMC0V), the LED is turned on in low light, then again ll and "enter"increases the intensity, ll and enter again and the light is at maximumbrightness. In contrast, if charge 9e9e5e5e1e1 and pressed successively ll and"enter", the light intensity does not decrease . However if write: while(TPMC0V!=0) { TPMC0V=0; } TPMC0V=0x001C * b_two - 0x5455B; Works well I suspect the problem may be the mechanism of loadcoherentización waiting two byte in a buffer before loading on TPMC0V.
3)I send PWM4.mcp for your scrutinizing. Any suggestion I well welcome Thank you Danielito PWM4.zip Message Edited by t.dowe on 2009-11-08 10:30 PM
|
|
|
|
2009-11-06 03:50 PM
|
|
|
|

|
Re: problems with TPMC0V
[ Edited ]
|
|
kef
Super Contributor
Posts: 608
Registered: 2006-02-02

Message 4 of 7

Viewed 83 times
|

|
|
First of all what's your compiler version? In IDE Alt+F7 -> Compiler for HC08 -> About Try disassembling both sequences (one with while() and another with &=0) and maybe post relevant asm lines and compiler options here. In both cases I get the same: 5f [1] CLRX 8c [1] CLRH 3500 [5] STHX _TPMC0V Options : -Cs08 -D__NO_FLOAT__ -Ms -WmsgSd1106 Message Edited by kef on 2009-11-06 07:48 PM
|
|
|
|
2009-11-06 05:45 PM
|
|
|
|

|
Re: problems with TPMC0V
|
|
Danielito
Contributor
Posts: 13
Registered: 2008-02-28

Message 5 of 7

Viewed 80 times
|

|
|
Compiler: Codewarrior IDE versión 5.9.0version 2404 (1993-2007) Compilerfor HC08: -Cs08-D__NO_FLOAT__ -Ms Disasssemble: withTPMC0V&=0X0000; 00aa5f [1] CLRX 00ab8c [1] CLRH 00ac3500 [5] STHX _TPMC0V With While() 00ac5f [1] CLRX 00ad8c [1] CLRH 00ae3500 [5] STHX _TPMC0V 00b0 LB0: 00b0 5500 [4] LDHX _TPMC0V See thereply a Jag Thank you.
|
|
|
|
2009-11-06 06:31 PM
|
|
|
|
|
|
|
|
|
|