This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541: Timer 1 interrupt with OSAL

Part Number: CC2541

Hi guys,

Did any of you managed to run Timer 1 interrupt with OSAL?

Cheers,

Kay

  • Hello,
    It should work to use timer 1.
    There is one example here and probably others if you search the forum.
    e2e.ti.com/.../2481491
  • Hi Eirik,

    Many thanks for the reply. I managed to get the interrupts working by removing def 'POWER_SAVING'. I reckon the OSAL sleep functions disable the interrupts and screw the time 1 interrupt.

    I had another funny thing happening - I coouldn't clear the OVFIF flag in the ISR due to whatever reason. I had to stop the timer first and then reset OVFIF. Following is the code.

    AL_ISR_FUNCTION(halT1_TimerIsr, T1_VECTOR)
    {
    HAL_ENTER_ISR();

    T1CTL &= ~(HAL_TIMER1_OPMODE_BITS); // clear OPMODE bits 1..0
    T1CTL |= HAL_TIMER1_OPMODE_STOP; //timer stoped to clear OVFIF

    T1STAT &= ~T1CTL_OVFIF; // clear the OVFIF - doesnt seem to be cleared when timer is running
    T1CNTL=0; // set timer back to 0
    T1CTL |= HAL_TIMER1_OPMODE_UPDOWN; // start timer again

    HAL_EXIT_ISR();

    return;
    }

    Any ideas?

    Cheers,

    Kay

  • Hello,
    Please refer to the CC2541 User's Guide (swru191f) section "2.5.1 Interrupt Masking".
    T1STAT is a W0 (write 0 to clear, write 1 has no effect) register. The first 2 bits are read only and the rest are all W0. The proper way to clear interrupt flags is by just writing 0. Try this instead:
    T1STAT = ~T1CTL_OVFIF;
  • Hi Eirik, Many thanks. That's how I initially tried it. Didn't work at that time. However I commented out the timer disabling statements I had earlier now and it is working!! I think the issue was I was having a breakpoint into the ISR and single stepping to see this bit clear. It doesn't seem to work like that. When it is running without breakpoint, it works.

    Thanks again,

    Kaushalya