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.
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.
#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 case 10: break; // Vector 10: ADC12BIN case 12: break; // Clear CPUOFF bit from 0(SR) case 14: break; // Vector 14: ADC12BMEM1 case 16: break; // Vector 16: ADC12BMEM2 case 18: break; // Vector 18: ADC12BMEM3 case 20: break; // Vector 20: ADC12BMEM4 case 22: break; // Vector 22: ADC12BMEM5 case 24: break; // Vector 24: ADC12BMEM6 case 26: break; // Vector 26: ADC12BMEM7 case 28: break; // Vector 28: ADC12BMEM8 case 30: break; // Vector 30: ADC12BMEM9 case 32: break; // Vector 32: ADC12BMEM10 case 34: break; // Vector 34: ADC12BMEM11 case 36: for(index =0;index< Num_of_Results;index++) { results[index] = ADC12_B_getResults(ADC12_B_BASE,memory[index]); } break; // Vector 36: ADC12BMEM12 case 38: break; // Vector 38: ADC12BMEM13 case 40: break; // Vector 40: ADC12BMEM14 case 42: break; // Vector 42: ADC12BMEM15 default: break; } }
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