uP = MSP430F2410
Task = Run timer b to up count to one second and then set the CCIFG flag.
Goal = Read the CCIFG flag, go do something, reset the up counter to zero, start all over again. I do not want to use and interrupt. I want to poll the interrupt flag ( I think)
Problem = The loop is running too fast and the IF statement is not running at one second. The output at P1.1 is always on (at least it looks like its on) How can I get the IF statement to trigger a fast pulse every one second and false.
Code:
#include <msp430F2410.h>
#define ONE_SECOND (32768) // ACLK counts in 1 sec
#define ONE_SECOND_TIMER TBCCR0 // RTC timer is TB6
#define ONE_SECOND_TIMER_CONTROL TBCCTL0
signed int timeout;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x02; // Set P1.1 to output direction
TBCTL = TBSSEL_1 + MC_1 + TBCLR; // ACLK = (watch crystal=32768), upmode,
// clear TBR
ONE_SECOND_TIMER = ONE_SECOND; // Set TBCCR0 to 32768 so timer
// will rollover at 1 sec (ACLK / 32768)
ONE_SECOND_TIMER_CONTROL = ( OUTMOD_4 ); // not sure if this is needed?
timeout = 0x00; // trying different things with this variable
for (;;)
{
if ( (TBCCTL0&CCIFG) != CCIFG )
{
P1OUT ^= 0x02;
}
}
} // end main