Hi,
I’m running FreeRTOS v7.6.0 on the cortex-M3 based STM32L151xB micro.
In my FreeRTOSConfig.h i have :
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
which makes me assume I have a tick triggering every millisecond.
Just to evaluate some application timing issues in relation to the tick I added GPIO pin toggling within the xPortSysTickHandler() to watch ticks on the oscilloscope, therefore in port.c I have :
void xPortSysTickHandler( void )
{
/* The SysTick runs at the lowest interrupt priority, so when this interrupt
executes all interrupts must be unmasked. There is therefore no need to
save and then restore the interrupt mask value as its value is already
known. */
#ifdef ST_DEBUG
GPIO_HIGH(GPIOC,GPIO_Pin_14);
#endif
( void ) portSET_INTERRUPT_MASK_FROM_ISR();
{
/* 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;
}
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );
#ifdef ST_DEBUG
GPIO_LOW(GPIOC,GPIO_Pin_14);
#endif
}
my debug code added under ST_DEBUG defines.
Using an oscilloscope I can see the xPortSysTickHandler() pulses sent on GPIO C, pin 14 , they all have a duration between 3 and 5 microseconds. Here are the issues :
1)I was expecting ticks pulses to be uniformly distributed at regular 1ms intervals with at most some jitter here and there, but the situation I see is slightly different. I have groups of few ticks interleaved by 1ms as expected and then some gaps 5 or 6 ms long in between groups; I was initially thinking that those long gaps were due to higher priority interrupt service routines but things didn’t change after disabling them. I was just wondering if there is something else I’m missing, can be some macro/service that needs to be disabled within FreeRTOSConfig.h ? What are your thoughts on this ?
2)Minor point : returning to the code snippet I pasted above, if my understanding is right, the task context switch is done once within xPortSysTickHandler() we run the following statement :
portNVIC
INTCTRL
REG = portNVICPENDSVSET_BIT;
which, as the comment suggests will cause the PendSV interrupt handler (as specified in portasm.s) to start running. So in general in this case the tick pulse duration measured as explained above might include the task switching time and pendSV interrupt time entry as well right ?
Thanks,
Adalberto