Hi,
I want to generate tick interrupt from other clock rather than systick.
i have created Timer for 1ms interrupt.
whether i have to remove systick timer?
(i.e #define xPortSysTickHandler SysTick_Handler)
i have followed from below link:
Normally using systick i have created tasks it is working according to there delays.
when i replaced my timer “NO TASK is running”.
Can anyone help me regarding this issue.
I think all the Cortex-M ports (I am assuming you are using Cortex-M as you mention SysTick, but we do support 40+ architectures) all have a method of using a timer other than the SysTick - please let me know which port and which compiler you are using and I will let you know how to do it.
Yes i am working on cortex m7 device Samv71 and also Nxp controller mpc5777c.
For samv71 i am using Atmel studio.
For MPC5777c S32 IDE.
please help me regarding this as i am new to rtos.
You need to do two things, define a function that configures a timer to generate a periodic tick interrupt, and install the FreeRTOS tick handling function as the timers interrupt handler.
To do the first simply define your own version of vPortSetupTimerInterrupt() - then the linker will link in your version rather than the weakly defined version in the FreeRTOS port layer as per the link above.
…And then if you want to use tickless idle, define portSUPPRESS_TICKS_AND_YIELD() as described on the main tickless idle documentation page. For Cortex-M, that really means provide your own vPortSuppressTicksAndSleep() function.
According to your suggestion, i added my timer configuration for 1millisecond periodic interrupt and timer handler.
i commented "#define xPortSysTickHandler SysTick_Handler " in freertos.h file.
In my timer_handler i ported piece of code from xPortSysTickHandler to my timer handler as given below. Every time it is going to dummy handler.
When systick is enabled it is working with exact event timing. Can you please help me regarding this issue.
portDISABLE_INTERRUPTS();
{
/* Increment the RTOS tick. /
if( xTaskIncrementTick() != pdFALSE )
{
/ A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
}
portENABLE_INTERRUPTS();
If the timer configuration is generating the interrupt as expected but it results in the dummy handler executing rather than your handler then you have not installed your interrupt handler in the vector table (or you have installed it in the wrong place).
Timer configuration are correct and generating periodic interrupt in the timer handler. but due to “systick handler” which i have commented in the code.
i.e : “#define xPortSysTickHandler SysTick_Handler”
In some part of freertos files which is calling systick handler. No task has been executing in my project.
when i uncommented the “#define xPortSysTickHandler SysTick_Handler”
my timer is generating tick increment and even systick also incrementing tick count. which results in mismatch of time slice between the tasks.
Double check you have the name of the function that sets up the interrupt correct so it is used in place of the default weekly defined symbol. Paste it into a plastic so we can check if you like.
In some part of freertos files which is calling systick handler
Note that nobody should call SysTick_Handler() directly, it is the name of an Interrupt Service Routine. Its address will be written in the interrupt (vector) table, and it will be called by the hardware.
Not sure if it adds anything to this discussion, but there are two ways to work with SysTick_Handler().
Either you ( or the HAL ) defines it, as for instance here:
__weak void SysTick_Handler(void)
{
if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
{
/* xPortSysTickHandler is defined in port.c */
xPortSysTickHandler();
}
/* The HAL functions sometimes use their own tick counter 'uwTick'. */
HAL_IncTick();
}
Or you use the #define xPortSysTickHandler SysTick_Handler, which makes that the function xPortSysTickHandler() in port.c becomes the ISR.
In that case, the HAL timer will not be updated automatically.
It is important to check that the correct SysTick_Handler() will be called. Try to grep for this string in the entire source tree. Or look into the LSS source listing and see which function will be used.
It is working in samv71 board.
For MPC5777c NXP controller : freertos is working using PIT timer. i need to change to STM timer.
In “prvPortTimerSetup” i replaced my timer functionality. it is triggering event with exact periodicity.
But No task has been executing since
if( xConstTickCount >= xNextTaskUnblockTime )
xNextTaskUnblockTime = 0xffffffff is becoming switching task is not happening.
is there any reason for why xNextTaskUnblockTime is becoming 0xffffffff.
Assuming the tick interrupt is configured using vPortSetupTimeInterrupt(), define your own implementation of that function that does nothing (just an empty function). Then your should get called instead of the one defined in the FreeRTOS kernel. Place a breakpoint in the function and run the application to ensure the breakpoint is hit to prove it gets called.
If it does get called, does the tick interrupt stop (so the LED stops toggling)? If not, then the tick interrupt is being configured elsewhere in the system, not by the kernel calling vPortSetTimerInterrupt() and you can stop the tick interrupt by disabling the PIT interrupt after it is configured.
If it does get called and the tick interrupt stops, then you can replace the empty function with the one that configures the timer you want to use and install an interrupt handler for that timer that increments the tick as per the instructions already given above.
If it doesn’t get called then the kernel code most have been changed somewhere.