Quality RTOS & Embedded Software

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




Loading

Sam4s xQueueReceive / xQueueSendtoBackFromIsr uxMessagesWaiting incorrect

Posted by sasukenebe on October 11, 2016

Hello,

The problem in a nutshell: My queue tells me there are no items, but the read/write pointers, as well as a debug counter tell me the buffer has 1-2 items left. Furthermore, looking at the raw uart traffic, it appears that some sort of corruption is possibly occuring with uxMessagesWaiting.

I am currently implementing a UART buffer using a freeRTOS queue. The bytes are received in an interrupt, and pushed to the back of the queue

if ( xQueueSendToBackFromISR(m_UartQueue,(void *)&InByte, &pxHigherPriorityTaskWoken) == pdTRUE )

where InByte is a uint8_t.

They are being popped off the queue in another thread.

xQueueReceive(mUartQueue, (void *)Byte, UARTRECEIVEWAITTIME); where byte is a uint8_t pointer.

I am finding by creating my own debug counter to compare to uxMessagesWaiting that the value differs from what my debug counters say. Within the interrupt the uxMessagesWaiting is often reporting 1 less than what I would expect.

I have verified that the interrupt priority of the interrupt is appropriately set relative to configmaxsyscallinterrupt_priority.

Baud rate is 38400, the buffer size is 256. 39 byte packets are being received.

I am out of ideas. Any advice is appreciated.

Thanks, Gary


Sam4s xQueueReceive / xQueueSendtoBackFromIsr uxMessagesWaiting incorrect

Posted by rtel on October 12, 2016

First - unless the bytes are arriving very slowing (for example, characters typed into a command console), then a queue is a very inefficient way of passing data out of an ISR. It would be better to use a DMA, or circular buffer and a direct to task communication to unblock a task when the buffer contains a complete message (http://www.freertos.org/vTaskNotifyGiveFromISR.html)

Which chip are you using? Do you have stack overflow detection turned on, and configASSERT() defined?


Sam4s xQueueReceive / xQueueSendtoBackFromIsr uxMessagesWaiting incorrect

Posted by sasukenebe on October 12, 2016

Thanks for the response. I am using the SAM4SD32C. I do have stack overflow detection turned on. I also have configassert defined. I will look into the alternative function you mentioned.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists