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

STM32F205 xPortPendSVHandler Problem

Posted by Pandi Vijayaraj on July 21, 2012
Hi,

I'm facing a problem while writing an UART application in STM32F205 using FreeRTOS.
I have two tasks one will send data out through UART and other will read data coming in through the same UART and process it.
I have assigned the Receiving task with priority (tskIDLE_PRIORITY+2) and writing task with the priority (tskIDLE_PRIORITY+1).
UART IRQ uses TXE interrupt to send data out and it receives a data for every occurance of the RXNE interrupt and places the data into a buffer, from which my receiving task will read.

I have used the NVIC Configurations as instructed in FreeRTOS manual
 
#define configKERNEL_INTERRUPT_PRIORITY 255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY15

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);


My Receive Task is blocked on a Binary semaphore which is actually released by IRQ handelr for every byte reception.
IRQ handler uses these calls to release the Semaphore

xSemaphoreGiveFromISR(ParseSem, &xHigherPriorityTaskWoken);
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);


My application works as i expected.
I dont face any problem when I send minimal amount of data out. If i periodically send data lessthan 50 bytes for a long time no problem.
If i try to send 300 bytes continuously, i'm receiving some of the data what i'm sending out and HardFault ocuurs.
I suspect a corruption in NVIC, it handles TXE as RXNE and my IRQ reads in the same data that is sent out.

Call Stack indicates the hardFault occurance in " xPortPendSVHandler+29 ".
If I trace this leads to xPortPendSVHandler

ldr r0, [r1]/* The first item in pxCurrentTCB is the task top of stack. */


I can't make much out of this hint. Also I tried to debug in many ways, like using Queue instead of Semaphore as shown in FreeRTOS example. But HardFault can't be prevented.

Thanks,
Vijayaraj

RE: STM32F205 xPortPendSVHandler Problem

Posted by Richard on July 23, 2012
If the fault is occurring on that line, then it looks like you have a RAM corruption somewhere that has corrupted the value loaded into R1 prior to that line of code.

Do you have stack overflow detection switched on?
Is your UART in an error state (overrun error, for example) that is not being handled?
How is your UART processing received bytes (placing them in a circular buffer, for example)?

Regards.

RE: STM32F205 xPortPendSVHandler Problem

Posted by Pandi Vijayaraj on July 23, 2012
Yes I have enabled stack overflow checking in my code. I have used the "vApplicationStackOverflowHook" to just print the name of the task having corrupted stack. But this vApplicationStackOverflowHook is never executed. Aiso i checked the size of stacks for all the tasks in FreeRTOS plugin for IAR. It is showing all the tasks having size >256.

My UART IRQ handler will receive a byte for every RXNE interrupt and copies it to a circular buffer. Then it will signal to a task using a semaphore.
For debugging purpose i tweaked this logic and implemented similar to a FreeRTOS demo program given for Cortex-M3. IRQ reads a byte for every RXNE interrupt and palces it in a queue. The corresponding task is blocked on the queue.
in this way i'm making sure data is read immediately after the occurrence of interrupt. But then also hardfault occurs.

Actually i should not receive the same data what i'm sending out. But i'm receiving some unwanted RXNE interrupts and reading the same data i'm sending out.

if i check UART overrun error flag after hardfault, it is set.


[ 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