ROB LUND

MCS908QGx simple timer problem

Discussion created by ROB LUND on Jul 18, 2006
Latest reply on Jul 19, 2006 by ROB LUND
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

Outcomes