Are you saying that executing the above instruction takes the control to prvTaskExitError? If yes, that does not seem correct as the above instruction does not alter PC. I am running out of ideas here - would you like to have a debugging session to debug this together. If yes, please DM me your email and some preferred time slots.
Hi Gaurav,
Yes that’s the observation i as seeing. i think we may not be calling “portSAVE_CONTEXT” as part of task context switching which i am checking more on this related to TCB access and then jumping to prvTaskExitError. Will let know if i found more info on this.
My mail id:- supreeth.i@synaptics.com
I have one quirey related to xTaskIncrementTick. In this there is api called as vApplicationTickHook. What code should we add here? any reference code can i get here
vApplicationTickHook will be called by each tick interrupt if configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used .
You can use this as a reference from Posix simulator, which calls this user code
I had not mapped the timer interupt for invoking the task switch for setting the ulPortYieldRequired, which is required to store the thread task in TCb.
Do not add anything. Set configUSE_TICK_HOOK to 0 in your FreeRTOSConfig.h.
Q2) so this code is not required for CR4 ? in that case why is this added if we don’t need
Hi Gaurav,
Still i am doing some code changes and still task scheduling is not happening
Q1) For now i have disabled api Tick Hook code and For getting timer to FreeRtos code for scheduling we need to use the Chip specific running clock based on ticks right? as this hook also seems to be runs based on ticks.
Q2) Where can we call this api “FreeRTOS_IRQ_Handler” from as this takes care of task switching. If we need to call this from Tr_irq interupt ? then is there any condition to be added to call this or we need to call every time when Tr_irq interrupt occurs
q3) we have api FreeRTOS_SVC_Handler, where can we use this? it seems like this api is used to start first task?
These questions suggest a potential gap in understanding how interrupts work. An interrupt can occur at any moment during program execution. When an interrupt is triggered, the processor core immediately halts its current operation and switches to executing the corresponding Interrupt Service Routine (ISR). The process unfolds as follows:
The core suspends its current task.
It then executes the appropriate ISR.
Once the ISR is completed, the core resumes its original task from the point of interruption.
You might wonder how the core determines which ISR to execute. Typically, there’s a predetermined location (or set of locations) to which the core jumps when an interrupt occurs. This information is stored in what’s known as the Interrupt Vector Table, which is usually situated at a fixed memory address. In the case of Cortex-R, the Interrupt Vector Table looks like the following:
You need to install FreeRTOS_SVC_Handler and FreeRTOS_IRQ_Handler in this table as shown here. FreeRTOS_IRQ_Handler is the common entry point for all the interrupts and its code roughly looks like the following:
FreeRTOS_IRQ_Handler:
/* Interrupt Entry code. */
vApplicationIRQHandler();
/* Interrupt Exit code. Context switch is handled here */
The application need to implement interrupt handling logic invApplicationIRQHandler. An example would look something like the following:
void vApplicationIRQHandler()
{
switch interruptCause:
{
case UART:
/* Handle UART interrupt. */
break;
case DMA:
/* Handle DMA interrupt. */
break;
case TIMER:
ulPortYieldRequired = xTaskIncrementTick();
break;
}
}