Problem with TBM

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

Problem with TBM

4,656 Views
afro
Contributor I
Hi,

I would like to use Timebase Module (TBM) in GP32. I set timebase rate to 1Hz but TBM generates too many tamebase interrupt. Please tell me what do I wrong. This is my code in CW08:

/* TBM interrupt handle */
void interrupt 16 tbm_interrupt()
{
if(LED_PIN == 1)
led_off();
else
led_on();
}

void main(void)
{
EnableInterrupts; // Enable interrupts
LED_DDR = 1; // Led pin as output

/* TBM (Timebase Module) */
TBCR_TBON = 0; // Disable TBM
TBCR_TACK = 1;
// Timebase rate to 1Hz
TBCR_TBR2 = 0; TBCR_TBR1 = 0; TBCR_TBR0 = 0;
TBCR_TBIE = 1; // Enable timebase interrupt
TBCR_TBON = 1; // Enable TBM

for(;:smileywink: {
__RESET_WATCHDOG(); // Watchdog
}
}

Thank you for your time
Labels (1)
0 Kudos
Reply
3 Replies

643 Views
rocco
Senior Contributor II
It does not look like you are clearing the timebase interrupt flag, so the TBM will re-interrupt as soon as you exit the ISR.

In your service routine, you need to write the TACK bit in the TBCR. Try this in the ISR:

TBCR_TACK = 1; // Clear interrupt

If that doesn't work, we will dig further . . .
0 Kudos
Reply

643 Views
afro
Contributor I
Hi

I put 'TBCR_TACK = 1' on the end of interrupt handle but it doesn't work. There is the same problem.

Thank you for your reply.
0 Kudos
Reply

643 Views
afro
Contributor I
Now it is OK. I used a wrong interrupt vector. Not 16 but 17.
0 Kudos
Reply