BluePill and FreeRTOS question

Working libraries, libraries being ported and related hardware
Post Reply
User avatar
Posts: 10
Joined: Tue Feb 13, 2018 2:41 pm
Location: Sunshine Coast, Australia

BluePill and FreeRTOS question

Post by jfitter » Thu Aug 23, 2018 3:08 pm

Would anyone have any idea what the problem is here.
I have stripped down the code to try to find out what is happening.
FreeRTOS is setup up for preemptive operation. I have several timers and tasks running. All of the tasks run at the same priority. The application runs fine except for this task and I can't figure out why.

Code: Select all

void vAcquireSensorDataTask(void *pvParameters) {
    while(true) {
//      vTaskDelay(1);
        if(driveFault == NOFAULT && rotorStatus == ONSPEED) {
            Serial.println("We are here");
void SetupSensorAcquistionTask() {
    BaseType_t th = xTaskCreate(vAcquireSensorDataTask,
                    tskIDLE_PRIORITY + 1,
Without the vTaskDelay(anything) the message is never printed. Test code shows that driveFault and rotorStatus are as expected, but execution never enters the conditional. The task is running because printing a message before the conditional works fine.
If a delay of even one tick is added then the conditional succeeds and the message is printed.

Any help appreciated. Thanks.

Posts: 3
Joined: Mon Aug 27, 2018 4:53 am

Re: BluePill and FreeRTOS question

Post by waqasaps » Mon Aug 27, 2018 5:15 am

sorry for late reply, did u manage to work it out?

Posts: 111
Joined: Thu May 31, 2018 5:39 pm

Re: BluePill and FreeRTOS question

Post by heisan » Mon Aug 27, 2018 7:28 am

Are you sure driveFault and rotorStatus are declared volatile?

Post Reply