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.

MSP430FR5994: How to change interrupt priority?

Part Number: MSP430FR5994

Hi,teams:

    I want to know how to modify the priority of the interrupt.According to the query information, the interrupt priority of MSP430 is arranged according to the size of the vector where it is located. The higher the interrupt vector address, the higher the priority.

Now, I use the ADC sampling interrupt and timer interrupt. According to the vector table address, I found that the priority of the ADC sampling interrupt is higher than that of the timer interrupt. If I want to make the timer interrupt priority higher than the ADC sampling interrupt, what should I do? 

Before:

Can I just swap their interrupt addresses?

After: 

#define ADC12_B_VECTOR    41*1U

#define  TIMER1_A0_VECTOR          46*1U

I look forward to your reply, thank you

  • Priorities are fixed and cannot be changed. (You can't change the vector addresses either.)

    A few MSP430s have an Interrupt Compare Controller which does allow for limited  adjustment of priorities, but this part doesn't have one.

  • On MSP430FR5994, according to device data sheet, 9.5 Interrupt Vector Table and Signatures, the interrupt priorities are fixed.

    Thanks David support and comments!

  • I now have two interrupts in the code, one is the ADC sampling interrupt and the other is the timer interrupt. The execution time of the ADC sampling interrupt service function is about 33ms; I set a timer interrupt every 2ms and count in the timer interrupt service function , when the count reaches 50 times, a 100ms time-out flag will be generated, and this flag will be used for timing operations later; with this setting, when the ADC sampling interrupt is executed, the low-priority timer interrupt cannot be responded to, which will cause the 100ms time base to be inaccurate.

    Now I can't change the priority of timer interrupt and ADC interrupt, how can I normally enter the timer interrupt to count when executing ADC interrupt?

  • 33ms is way to long to spend in an ISR. You should change that.

    Since GIE is cleared when an ISR starts, the interrupt priority doesn't matter since no interrupts will be serviced till the ADC ISR exits.

  • Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(ADC12_VECTOR)))
    #endif
    void ADC12_ISR(void)
    {
    static uint16_t index = 0;
    static uint8_t memory[Num_of_Results]={ADC12_B_MEMORY_0,ADC12_B_MEMORY_1,ADC12_B_MEMORY_2,ADC12_B_MEMORY_3,
    ADC12_B_MEMORY_4,ADC12_B_MEMORY_5,ADC12_B_MEMORY_6,ADC12_B_MEMORY_7,
    ADC12_B_MEMORY_8,ADC12_B_MEMORY_9,ADC12_B_MEMORY_10,ADC12_B_MEMORY_11,
    ADC12_B_MEMORY_12,} ;
    switch(__even_in_range(ADC12IV,42))
    {
    case 0: break; // Vector 0: No interrupt
    case 2: break; // Vector 2: ADC12BMEMx Overflow
    case 4: break; // Vector 4: Conversion time overflow
    case 6: break; // Vector 6: ADC12BHI
    case 8: break; // Vector 8: ADC12BLO
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Is there any problem with writing the interrupt service function like this?

  • In order to solve the problem of inaccurate timer counting when the ADC is running, now I change the timer interrupt to 50ms, and at the same time read the value collected by the ADC once every 50ms, I don’t know if this is feasible

  • How to change the interrupt service function to reduce the interrupt execution time?

  • The general practice is to store the data somewhere, quickly. Then exit low power mode so that the foreground process can do the work.

    But so far you haven't shown anything that should be slow. So I have no idea where you got 33ms.

**Attention** This is a public forum