Quality RTOS & Embedded Software

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




Loading

coding problem - AT91SAM3U4E + IAR

Posted by vito v on May 30, 2013
Hello,
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.

Example:
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
... ....
for(;;)
{
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,
Vito

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.

Regards.

RE: coding problem - AT91SAM3U4E + IAR

Posted by vito v on June 1, 2013
Hi,

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.
Vito


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().

Thanks,
Vito


[ 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