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

ISR and queue handling

Posted by Casper Hedegaard on January 14, 2013
Hello

Controller: Atmel UC3A0512
Enviroment: ARV32 Studio

I have a USART interrupt which is like this:

__attribute__((__interrupt__)) static void usart_int_handler( void )
{
static int status, temp;
static uint8_t data;

static portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;

// Read USART buffer
status = usart_read_char( USART_CHANNEL, &temp );

if( USART_RX_ERROR == status)
{
// Resetting the USART
usart_reset( USART_CHANNEL );

// Enable the USART as RS485
InitCOM();
}
else if( USART_SUCCESS == status )
{
data = (uint8_t)temp;

// Because FreeRTOS is not supposed to run with nested interrupts, put all OS calls in a critical section
portENTER_CRITICAL();
xQueueSendToBackFromISR( xRXQueue, &data, &xHigherPriorityTaskWoken );
portEXIT_CRITICAL();
}

if( xHigherPriorityTaskWoken == pdTRUE )
{
// Force unblocked (higher priority) tasks to run
vTaskSwitchContext();
}
}


I'm running in multidrop mode and I have 2 slave modules connected to this RS485 bus.

My problem is that when my task, which is looking at this xRXQueue, is seeing data in the queue and starts to read the queue, the system breaks down and restarts do to my watchdog. The task starts like this:

if( pdPASS == xQueueReceive(xRXQueue, rx_buf, portMAX_DELAY) )
{
// code here
}


How can I, in a more secure way, handle this queue and interrupt handling so it will not stall the controller?

Best regards
Casper

RE: ISR and queue handling

Posted by Richard on January 14, 2013
There does not look to be anything fundamentally wrong with your implementation. Are you using the ARV32 port that is distributed by Atmel, which is the version for the latest AV32 chips?

Regards.


[ 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