Tool/software:
Hello!
Everything is in the title. Almost.
I would like to temporarily disable interrupts when I enter the ISR and re enable them at the end of the ISR.
In the following example, I use timer B to get a recurrent interrupt.
The timer itself seems to work, and I have verified with a scope that P10 bits are toggled and that
the period depends on the TBCCR0 value.
Now in order that the program doesn't step on its own feet, I would like to disable interrupts as soon
as it enters into the ISR.
I could verify that:
- The interrupt enable works, be it _EINT(), _enable_interrupts(), bis_SR_register(LPM0+GIE), and possibly
other variants.
- The program doesn't change (i.e. it still works) even if I don't re-enable interrupts at the end of the ISR,
as shown in the following program. I have not re-enabled the interrupts, so it should stop once only in the ISR,
right? But it still works the same (no difference with _EINT() uncommented).
I tried all the variants above with replacing by the relevant function.
Question: is there anything wrong? Is it possible to temporarily disable the interrupts?
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= 0x01; // P1.0 output TBCCTL0 = CCIE; // CCR0 interrupt enabled TBCCR0 = 50000; TBCTL = TBSSEL_2 + MC_2 + TBCLR; // SMCLK, contmode, clear TBR // _enable_interrupts(); __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts // __no_operation(); // For debugger } // Timer B0 interrupt service routine #pragma vector=TIMERB0_VECTOR __interrupt void TIMERB0_ISR(void) { // _disable_interrupts(); __bic_SR_register(LPM0_bits + GIE); P1OUT ^= 0x01; // Toggle P1.0 TBCCR0 += 50000; // Add Offset to CCR0 [Cont mode] // _EINT(); }
By the way: how can I send an image? There is no browse option in the menu -> insert -> image / video file.
If I try to drop a file on the popup window, then I can see the image in my navigator window, but that's not exactly
what I want.
Thanks,
R