STM32 F101CProgram goes to HardFaultException

Hello All.
I’m trying to run FreeRtos on STM32F101C8. I have 2 simple tasks:
static void vLCDTask( void *pvParameters )
{
  (void)(*pvParameters);
    for(;;)
    {
      GPIOB->ODR &= 0x03FF;
      vTaskDelay(1);
    }
 }
static void vLSDTask( void *pvParameters )
{
  (void)(*pvParameters);
    for(;;)
    {
        GPIOB->ODR |= 0xFC00;   
        vTaskDelay(1);
    }
 }
I debug with IAR jtag emulator and see that each of them is executed only once. After that program goes to HardFault Exception. If I add one more task – it goes through 3 tasks. If I replace xTaskDelay by TaskYield() it works good. I use IAR 5.41 compiler.
Thanks

STM32 F101CProgram goes to HardFaultException

Is there a standard demo application you can try? Are you running into mutual exclusion having two tasks attempting to access the same port so rapidly?

STM32 F101CProgram goes to HardFaultException

Unfortunately I have only a board with STM32F101C8 and standard demo is designed for STM32F101F103. So, I simplified standard demo reducing it to these small tasks, modified linker script file stm32f10x_flash.icf and changed value f the CPU clock frequency to 24MHz. The 1ms delay  seems to be large enough to provide access to port, isn’t it? I initially tried vTaskDelay(1000).
Maybe there is a reference to STM32F101C8 FreeRtos example somewhere?

STM32 F101CProgram goes to HardFaultException

>  Unfortunately I have only a board with STM32F101C8 and standard demo
> is designed for STM32F101F103. So, I simplified standard demo
> reducing it to these small tasks, modified linker script file
> stm32f10x_flash.icf and changed value f the CPU clock
> frequency to 24MHz. You are doing the right things, but did you start with the project for the standard demo you mention, or create a new project? > The 1ms delay  seems to be large enough to
> provide access to port, isn’t it? I doubt this is the source of your problem, but it is worth looking at. The delay period does not provide mutual exclusion, if a tick interrupt occurs between reading the current port value and writing the new one then you have a problem. I don’t think it would make it crash though. Look at the partest.c files in the FreeRTOS/Demo directory to see how they do port access.

STM32 F101CProgram goes to HardFaultException

I downloaded demo project and modified it deleting everything except LED blinking. After that I customized LED ports to my board ports and pins. Preliminary I wrote a separate simple program to test board LEDs switching.
Thanks, I’ll look at partest.c

STM32 F101CProgram goes to HardFaultException

Well, I replaced LED blinking with a++ and b++ operations, where a and b are two long globals.  I still have Hard Fault Exception but I noticed that the system works about two second before it catches it. Can it be something with bus timing?