TI MSP430 Interrupt Source

I know that when working with MSP430F2619 and TI CCSv4, I can get more than one interrupt to use the same interrupt handler with code that looks something like this:

#pragma vector=TIMERA1_VECTOR #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void){ ServiceWatchdogTimer(); } 

My question is when I am in this interrupt, is there a way to find out which of these interrupts brought me here?

+4
source share
3 answers

A general answer to your question: There is no direct method for detecting which interrupt is currently being called. However, each interrupt has its own interrupt flag, so you can check each flag in the interrupt. You must also enable the flag to ensure that you are handling the interrupt that was actually called. Also with timers on the MSP430 there is a TAIV vector that can tell you what to process in the A1 handler. Case 0 TAIV is the absence of an interrupt for handler A1, so for this case you can assume that it is handler A0.

I would do something like the following.

 #pragma vector=TIMERA0_VECTOR #pragma vector=TIMERA1_VECTOR __interrupt void Timer_A (void) { switch (TAIV) // Efficient switch-implementation { case TAIV_NONE: // TACCR0 TIMERA0_VECTOR break; case TAIV_TACCR1: // TACCR1 TIMERA1_VECTOR break; case TAIV_TACCR2: // TACCR2 TIMERA1_VECTOR break; case TBIV_TBIFG: // Timer_A3 overflow TIMERA1_VECTOR break; default; break; } ServiceWatchdogTimer(); } 
+5
source

Not quite a “good” answer, but why not make 2 separate interrupt handlers the same function?

sort of

 __interrupt void Timer_A0_handler (void){ Timer_Handler(0); } __interrupt void Timer_A1_handler (void){ Timer_Handler(1); } void Timer_Handler(int which){ if(which==1){ ... }else{ ... } ... ServiceWatchdogTimer(); } 
+2
source

Looking at the MSP430x1xx Family User Guide , it seems that the device does not support the interrupt status register with this information directly. You will need to have 2 separate interrupt vectors so that you can directly identify the difference, or you will need to query both devices to find out which one is needed.

If you use 2 interrupt vectors, they can, of course, call or go (if you use the assembly) to the same procedure to do the bulk of the work, as in the answer by Earlz .

Please note that the chip already has an interrupt vector table, so to do what you say in the comment you made in another answer, you just need to specify the interrupt vector entries for the “unused” interrupts that cause an error.

+2
source

Source: https://habr.com/ru/post/1306849/


All Articles