0

Hi i am trying to set up an overflow timer interrupt on Timer 3 of an 8051. The code is getting stuck in the interrupt routine. i am using the 2511F32 (wixel)

Here is the interrupt setting code:

{ ......

T3CTL |= 0xE0;                  // set prescaler to tick frequency / 128 (DIV) bits 7:5
T3CTL |= 0x04;                  // Clear counter value (CLR - bit 2)
T3CTL |= 0x00;                  // Timer mode set to free running (00) bits 1:0
T3CTL |= 0x08;                  // Enable overflow interrupt (OVFIM) bit 3

T3CCTL1 &= ~0x40;               // disable timer compare interrupts
T3CCTL0 &= ~0x40;               // disable timer compare interrupts

IEN1  |= 0x08;                  // Enable Timer 2 interrupts


T3CTL |= 0x10;                  // Start the timer (START - bit 4)

EN = 1;

......

}

Here's the interrupt routine code

ISR(T3,0)
{
    TIMIF &= ~0x07;      //   T3OVFIF Clear T3 overflow interrupt flag - bit 0
    LED_YELLOW_TOGGLE();
}

It remains trapped in the ISR routine. There are no other interrupt flags to clear. Any ideas ?

jelipito
  • 171
  • 2
  • 2
  • 12
  • What does LED_YELLOW_TOGGLE() do? Can you post the code of that also? – Martin Thompson Feb 12 '13 at 11:12
  • @MartinThompson it is just an I/O pin toggle: #define LED_YELLOW_TOGGLE() {P2DIR ^= 0x04;} – jelipito Feb 12 '13 at 16:38
  • @UncleO - That is clearing the CPU interrupt flag, spec says it is automatically cleared by hardware, just to test i also added that line, same behavior. I have timer1 also workni which is 16 bits, and has different interrupt flags with no issues – jelipito Feb 12 '13 at 16:39

1 Answers1

0

how do you say that the code is stuck in the ISR? if the led is toggling then the interrupt is enabled all the time and the isr is called as soon as it finishes. it never returns to the main code..

Koushik Shetty
  • 2,146
  • 4
  • 20
  • 31
  • Hi i found the problem. The MCU has a bootloader and it is by reading P2_2 which is the yellow led pin as well, so it was entering bootloader mode. It is working now. thanks everyone – jelipito Feb 14 '13 at 20:24