coding problem – AT91SAM3U4E + IAR

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

coding problem – AT91SAM3U4E + IAR

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.

coding problem – AT91SAM3U4E + IAR

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

coding problem – AT91SAM3U4E + IAR

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