problems with TPMC0V

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problems with TPMC0V

1,701 Views
Danielito
Contributor I

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 

Labels (1)
Tags (1)
0 Kudos
6 Replies

815 Views
jag
Contributor IV

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 

 

 

 

0 Kudos

815 Views
Danielito
Contributor I

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
0 Kudos

815 Views
kef
Specialist I

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
0 Kudos

815 Views
Danielito
Contributor I

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.

 

0 Kudos

815 Views
kef
Specialist I
Like may be seen in disassembled code, in both cases TPMC0V is cleared the same way!
0 Kudos

815 Views
Danielito
Contributor I

I see a line more related to load  TPMC0V, therefore not appear assame way.Morover, in the case of setence While() should be expected to enforcethe condition that TPMC0V to clear before exitin the loop. At least is what Iunderstood by now.

Thank you 

0 Kudos