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.

Question about how ISR work

Other Parts Discussed in Thread: MSP430F5438

Hi,

I am using MSP430F5438 and I am currently studying the sample project, the "User Experience". I kind of confuse about how the ISR work. 

First of all, I saw there are interrupt functions of timer B both in audio.c and adcTemp.c. Two interrupt functions have different name.

One is __interrupt void TIMERB1_ISR(void) and another is __interrupt void TIMER0_B0_ISR(void). Since I saw there is no timer 0 but only timer B in MSP430F5438, so I believe the second interrupt function is also for timer B. But here is the problem. How can I know if which ISR will be triggered if I set up the timer B?

I also have the question that where is those function names come from? 

Thanks.

Shan

  • Hi,

    i do not know the specific case of the  MSP430F5438, but in general there can be multiple Timer_B modules on a given device (see the device-specific data sheet). Every module can also generate more than one interrupt. For example interrupts may be generated from the counter on overflow conditions and from each of the capture/compare registers.

    In order to set which interrupt will be trigger, you have to set the timer B registers according with you need. Check the MSP430F5438 User's Guide for the timer B register settings!

    Shan Liang said:

    I also have the question that where is those function names come from? 

    You can find ISR names in the header file msp430F5438.h. You will find it in ../Programs/Texas Instruments/ccsv4/msp430/include

     

    Regards,

    Carloalberto

  • Actually, those names are "user defined" and have no significance to the compiler/linker/debugger. You can change those names if you want. For example, call an ISR "This_is_not_an_ISR" and it will still work as an ISR.

  • But if we defined our own interrupt function name, how could MSP430 know whether the ISR function is for Timer or ADC, for example?

  • Hi,

     

    An interrupt service function is defined with the pragma directive, e.g.,

    #pragma vector = PORT1_Vector

    __interrupt void myISR(void)

     

    This will tell to the Linker to place the address of this function in a special place, the interrupt table stored at the end of flash. Each time the interrupt flag from PORT1 is raised, if both the General Interrupt Enable (GIE) and the Port1 Interrupt Enable (P1IE) are enabled, then the Program Counter (PC) and the Status Register (SR) are stored in to the system stack. After that, the PC is loaded with the address of myISR retrieved from the vector interrupt table.

     

    Best Regards,

    AES

  • AES said:

    Hi,
    An interrupt service function is defined with the pragma directive, e.g.,
    #pragma vector = PORT1_Vector
    __interrupt void myISR(void)
    This will tell to the Linker to place the address of this function in a special place, the interrupt table stored at the end of flash. Each time the interrupt flag from PORT1 is raised, if both the General Interrupt Enable (GIE) and the Port1 Interrupt Enable (P1IE) are enabled, then the Program Counter (PC) and the Status Register (SR) are stored in to the system stack. After that, the PC is loaded with the address of myISR retrieved from the vector interrupt table.
    Best Regards,
    AES

    I would like to point out that "PORT1_Vector" is also  "user defined". For MSP430F5838, it should be equal to 0x5E so that the "special place" is 0xFF80+0x5E=0xFFDE for PORT1 Interrupt Vector.

    Often we define a lot of different words as substitutes for a lot of different things in order to make them "easier to understand". But that kind of "understand" is often worse than "not understand".

  • As I told in my last post, you can find the definition in msp430f5438.h :

    #define TIMER0_B0_VECTOR        (60 * 1u)                    /* 0xFFF8 Timer0_B7 CC0 */
    /*#define TIMER0_B0_ISR(func)     ISR_VECTOR(func, ".int60")  */ /* 0xFFF8 Timer0_B7 CC0 */ /* CCE V2 Style */

    Therefore if you would like to rename also the vector in the pragma you should re-define it in this way (I would not modify the original msp...h, so place the define in another place):

    #define TIMER0_B0_YOUR_VECTOR_DEF        (60 * 1u)                    /* 0xFFF8 Timer0_B7 CC0 */

     

    Carloalberto

  • Shan Liang said:
    How can I know if which ISR will be triggered if I set up the timer B?

    There can well be two ISRs assigned to one timer. Each tiemr has two interrutp vectors. One is triggered by the CCR0 module (asn clears the CCRIFG bit when called automatically), the ohter one is for teh tiemr overflow interrupt as well as for all other CCR units of this timer.

    The names of the ISRs and the vectors depen on the system. The mspgcc notation for the vector is TIMERx_yz_VECTOR, where y is the timer type, x the timer number and z the trigger.

    TIMER0_B0 is the vector for the CCR0 unit in Timer B0, whiel TIMER0_B1 is the vector for all other interrupt sources in timer B0. On other compilers, the names may vary. As does the notation how to tell the compiler/linker where to put the function reference in the vector table. One possibility is a #pragma line right before the ISR. Or as parameter to the _interrupt prefix or as function attribute (mspgcc compiler).

    Then there is the ISR function name, which can be freely chosen. This is your TIMERB1_ISR or TIMER0_B0_ISR. It's just a name like foo() and bar(). Important is the vector these two are assigned to. In this case I'd guess that the second one is for TimerB CCR0 interrupt, while the first one is for all other interrupts in TimerB.

**Attention** This is a public forum