Quality RTOS & Embedded Software

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


coding problem - AT91SAM3U4E + IAR

Posted by vito v on May 30, 2013
i am new with this board.

I am using the CORTEX_AT91SAM3U256_IAR port of FreeRTOS with IAR WorkBench.

I'm trying to make my own code customization, but something very strange happens. If i put any line of code, it hangs and stay in the HardFault handler exception.

i just add some simple lines, without modifying anything else in the file comtest .c in the function:

static portTASK_FUNCTION( vComTxTask, pvParameters )
static unsigned short int i; // i declare a simple int variable
... ....
if (i<100) i++; // and i do this

The IAR WorkBench debugger, does not even enter in the main() function, but locks in the while of the HardFault handler in the file exceptions.c

Maybe am i ignoring something ? or just lack some knowledge ?

Thank you in advance,

RE: coding problem - AT91SAM3U4E + IAR

Posted by Richard on May 31, 2013
Before answering your question - the use of the portTASK_FUNCTION() macro is not necessary. Just write
static vComTxTask( void *pvParameters ) directly (that is what the macro expands to).

Am I right in thinking you have the example as distributed (without your modifications) working as expected, and that this problem only happens when you add code? If so then the most likely reason is that you have run out of heap space and the scheduler is just not starting. Try adding a forever (for(;;)) loop after the call to vTaskStartScheduler(). If you have insufficient FreeRTOS heap then vTaskStartScheduler() will return and you will end up in the loop. Alternatively you can add a malloc() failed hook function and see if the hook function is ever called.

Assuming this is your problem then either increase the size of the FreeRTOS heap, or reduce the amount of heap that is used by stopping some of the standard demo tasks from being created.


RE: coding problem - AT91SAM3U4E + IAR

Posted by vito v on June 1, 2013

i guess it could be not the cause of the problem.
I use the AT91SAM3U256 port as is.

If i comment out one of the test tasks the main() is running, the system hangs, and does not start anything.
I commented out the vAltStartComTestTasks, and the system hanged.

I tried what you suggested me, inserted a for(;;) after the vTaskStartScheduler(), with vAltStartComTestTasks still commented, and the system started ok.
So, i commented out vStartLEDFlashTasks() too. And the system hanged again.

Thank you for the help.

RE: coding problem - AT91SAM3U4E + IAR

Posted by vito v on June 8, 2013
I found the problem.

The problem is in LowLeveInit() function, it hangs before the application starts, sometime on the setting of the Watchdog, other times on initialization of the main oscillator other times on the init of setting of the ext/main clock.
Now i know the problem, but don't know what causes it.

I commented out the init of the watchdog and main oscillator, and now it hangs less often than it did.
But still, when i add/remove some code it hangs, so i have to add/remove another line or function to call, like vTaskDelay().


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

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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

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

Xilinx Microblaze and Zynq partner