Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

xTicksToWait within xQueueSendToBack

Posted by Fabien on April 16, 2013
Hello,

I would like to use xQueueSendToBack function with a block time, so I write the next program:
xQueueSendToBack(xQueue1, ( void * ) &Data, ( portTickType ) 100 );

When I tried to debug this function, I go directly to xQueueGenericSend and the value of xTicksToWait is always 0 instead of the value I have set (100).

Could you please help me to understand this behavior?

For information, I work with:
- FreeRTOS V6.1.1
- EWARM 6.21.3
- Compiler optimisation for FreeRTOS set to High (Speed)


Thanks for your help,
Best regards,
Fabien

RE: xTicksToWait within xQueueSendToBack

Posted by Richard on April 16, 2013
xQueueSendToBack maps to xQueueGenericSend so that is expected. At high optimisation you may see the variable as zero in the debugger because there is no direct relationship between the source code and the object code. Do you see the same thing when you compile with zero optimisation?

Regards.

RE: xTicksToWait within xQueueSendToBack

Posted by Fabien on April 17, 2013
Hi Richard,

Thanks a lot for your reply.
I tried to compile with zero optimisation and the result is the same. When I enter inside the function:
xQueueSendToBack(xQueue1, ( void * ) &Data, ( portTickType ) 100 );
The value of xTicksToWait is always 0 instead of 100.

Do you have any idea?

Thanks for your help,
Best regards
Fabien

RE: xTicksToWait within xQueueSendToBack

Posted by Richard on April 18, 2013
“Do you have any idea?”


Sorry no - this is just C code. If you pass a parameter into a C file I would expect the compiler to generate code that passed the parameter into the function. All I can suggest is that you step through the assembly code to see the parameter getting placed into a register outside of the function call, and then see the value getting read out of the register inside the function call.

If the parameter is passed on the stack rather than in a register ensure the stack pointer is correctly aligned at that point in the code.

If you suspect a context switch is occurring in between calling the function and entering the function and that somehow that is corrupting the register value then try entering a critical section before calling the function (call taskENTER_CRITICAL()) just as an experiment [API functions must not be called from critical sections normally, this would be just an experiment while you were stepping through the code].

Regards.

RE: xTicksToWait within xQueueSendToBack

Posted by Fabien on April 18, 2013
Hi Richard

I tried your suggestion to call taskENTER_CRITICAL() before to call xQueueSendToBack and it works fine.
I made some tests and found that it was a context swith done by one interrupts. Thanks a lot for your useful feedback.
Adding taskENTER_CRITICAL() was just for debug purpose, so I removed it and I will look now to fix this issue in my software.

Best Regards,
Fabien


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS