I am using FreeRTOS on STM32L15RD processor--a STM32L152 variant, and using
the Rowley Crossworks for ARM as a toolchain. My problem is when a I set a timer
for what I think is 10000 milliseconds it doesn't expire until approximately 17000
The timer is created as follows:
TSAMPLE = xTimerCreate("Sample T", (10000/portTICKRATEMS), pdFALSE, &v, samplehandler);
The underlying definition of portTICKRATEMS in FreeRtosConfig.h is as follows:
define configTICKRATEHZ ( (TickTypeT) 1000)
This is the timeout handler.
void samplehandler(TimerHandlert timerid)
msg.event = AGG_E_SAMPLE_TIMEOUT;
msg.data_len = 0;
msg.data = NULL;
xQueueSendToFront(AGGREGATE_TASK, &msg, portMAX_DELAY);
The timer is started and handled in AGGREGATE_TASK and the only thing the task
is doing is waiting for a message as follows:
(i.e. No messages except the timeout message arrive.)
xQueueReceive(AGGREGATE_TASK, &msg, 0);
Do you have any idea what the problem is ?
xQueueSendToFront(AGGREGATETASK, &msg, portMAXDELAY);
You are not supposed to make any Blocking function calls in timers, as to do so will Block the timer task itself, and effect any other timers that might be running. That may be the cause of the problem, but also....
Are you sure the tick interrupt is executing at the frequency you think it is? Can you toggle a pin from a tick hook function and check its frequency on a scope or frequency meter?
I don't think that is the problem becuase if one substibutes
xQueueSendToFrontFromISR(), the problem persists. In any case,
the queueing functions don't do much more than a linked list
I don't have a scope handy but is is possible the
clock is not configured as I think. The file with
the clock initialization routines is attached to this note.
I'm afraid the configuration of microcontrollers falls outside of FreeRTOS support. Even toggling an LED once per second and timing 60 toggles will give you a gross assessment of how the frequency of the tick count. Also ST provide a spreadsheet that automates clock configuration - you can enter your settings into the spread sheet and it will tell you the frequency of the output clocks.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.