AnsweredAssumed Answered

STM32F0 Discovery -> Demo source hard faults???

Question asked by ro.dru on Nov 4, 2013
Latest reply on Nov 5, 2013 by ro.dru
I got the IAR tool chain installed and downloaded the discovery kit firmware package from the page:

I open the STM32F0-Discovery-Demo and then in IAR select Project->Download and Debug.

I anticipate the LED's turning on just like when the board was powered up through USB before programming and...... nothing.

So I go through the code step by step in the debugger to try track down the problem and here is what I get:

In main the following is called:
  /* Configure LED3 and LED4 on STM32F0-Discovery */

Which you end up in stm32f0xx_gpio.c at:
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

In this function the following is called:
        /* Speed mode configuration */
        GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));

If I hit F11 step into on this line the LED debugger light on the board flashes and nothing further happens.  When I hit break I end up at the following:

void HardFault_Handler(void)
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)

What??? How is it possible that the factory demo code does not work for a simple LED blinking example.  I have to assume due to my experience that I am missing something but what is it?

I am at a loss of even what the do next, do I start messing around in the stm32f0xx_gpio.c file?  I find it hard to believe that there would be an error with the above code since it is such a basic example that comes pre-installed, so any trouble with this code should have been long sorted out.

I installed IAR in a virtual machine (Windows 7) for testing purposes running on a Windows 8 computer.