MCS908QGx simple timer problem

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

MCS908QGx simple timer problem

1,523 Views
irob
Contributor V
One of those days. I can't seem to get the free-rolling timer to start. Actually, I can get it to run sometimes in background debug mode, but it's sporadic. Sometimes, the timer runs, other times it gets lost in the weeds. When I step through code, I can definitely see the TMPCNT register incrementing.

Here's my code:

EnableInterrupts;
TPMSC_CPWMS = 0;
TPMSC_PS = 0b100;
TPMMOD = TIMEOUT;
TPMC0SC_MS0x = 0b01;
TPMC0SC_ELS0x = 0b00;
TPMCNT = 0; // reset counter
TPMSC_CLKSx = 0b01;

for (;:smileywink:
{
__RESET_WATCHDOG();

while (!TPMSC_TOF)
{
if (!SW1)
{
LED2 = OFF;
LED1 = ON;
TPMCNT = 0; // reset counter
}
else LED1 = OFF;
}

LED2 = ON;

if (TPMSC)
{ // dummy read
}
TPMSC_TOF = 0; // reset counter flag

} // Loop forever


Anyone see where I strayed? I checked out this thread about the order of configuring the timer and set my clock source last. Still no go.

Message Edited by irob on 2006-07-18 06:00 PM

Labels (1)
0 Kudos
1 Reply

258 Views
irob
Contributor V
Oops, I found it. Needed another watchdog timer reset here:

while (!TPMSC_TOF) // output timer compare loop
{
__RESET_WATCHDOG(); // Kicks the dog
if (!SW1)
...
0 Kudos