Hi All,
Everytime i am using From_ISR calls the cpu halts completely.
Details on environment:
- microcontroller being used - ATSAMG55J
- Development IDE - Atmel studio 7
- Freertos version 10.0.0
- configMAX_SYSCALL_INTERRUPT_PRIORITY = ( 4 << 4) (beacuse G55 has higher 4 bits for interrupt priority level)
- configLIBRARY_LOWEST_INTERRUPT_PRIORITY = 0x07
Task I am trying to achieve:
I have 4 tasks running parallelly and I have configured an uart to send instructions to the MCU. Originally i intended to implement an UART ISR but it wasnt working so I tied the RX pin to one of the available GPIO pin(PA24) and wrote an ISR for that. As at now I have used “NVIC_SetPriority(27,0x0f);” from CMSIS which has __NVIC_PRIO_BITS = 4 to set the interrupt priority of ISR to 0xf0 (which is highest in numerical value and thus lowest in priority).
I am double checking m interrupt priority by following lines:
uint32_t ulCurrentInterrupt,ulCurrentInterruptPriority;
__asm volatile("mrs %0, ipsr" : "=r"(ulCurrentInterrupt)::"memory");
printf("%d - %x\n",ulCurrentInterrupt,ulCurrentInterrupt); // OP -> 27 - 1b
ulCurrentInterruptPriority = NVIC_GetPriority(ulCurrentInterrupt);
printf("pri - %d\n",ulCurrentInterruptPriority); // OP -> pri - 15
ulCurrentInterruptPriority = pcInterruptPriorityRegisters[ulCurrentInterrupt + 0x10];
printf("pri - %d\n",ulCurrentInterruptPriority); // OP -> pri - 240
vPortValidateInterruptPriority();
The call to vPortValidateInterruptPriority(); was blocking the CPU and when i looked within that function i found this line:
ucCurrentPriority = pcInterruptPriorityRegisters[ulCurrentInterrupt] ;
Here pcInterruptPriorityRegisters was initialized to 0xE000E3F0 but according to datasheet the address of the first user defined interrupt starts from 0xE000E400. And thus the call to vPortValidateInterruptPriority() was actually looking at a different location. I corrected this by modifying it to:
ucCurrentPriority = pcInterruptPriorityRegisters[ulCurrentInterrupt+portFIRST_USER_INTERRUPT_NUMBER]
//portFIRST_USER_INTERRUPT_NUMBER = 0x10
This did allow the CPU to not halt at the first call to vPortValidateInterruptPriority();.
After that, at the end of the ISR i am calling:
xResult = xEventGroupSetBitsFromISR(g_xEventGroup,0x04,&xHigherPriorityTaskWoken);
Which returns success but then i dont see any output from any of the other threads.
What am i still missing here?