# STM32F discovery doesn't execute code after programming successfully

I have a stm32f051R8T6 Discovery board, and I compiled a simple blinking LED code to activate the LED's on the board itself. The code builds successfully and flashes the MCU but the MCU won't execute the code, I have reset it and tried programming it with a different code which worked in the past but still no luck, I am working in Coocox.

Once I have the hex file I flash the MCU with either the STM32 st-link unity or Coocox itself and both say it flashes successfully

I think the MCU is held under reset but I'm not sure and I don't know how to get it out.

Code is Below

#include "stm32f0xx.h"

void delay(const int d);

int main(void)
{
// GPIOC Periph clock enable
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;

// PC8 and PC9 in output mode
GPIOC->MODER |= (GPIO_MODER_MODER8_0 | GPIO_MODER_MODER9_0);

// Push pull mode selected
GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9);

// Maximum speed setting
GPIOC->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR8 | GPIO_OSPEEDER_OSPEEDR9);

// Pull-up and pull-down resistors disabled
GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPDR8 | GPIO_PUPDR_PUPDR9);

while(1)
{
// Set PC9
GPIOC->BSRR = GPIO_BSRR_BS_9;
// Reset PC8
GPIOC->BSRR = GPIO_BSRR_BR_8;
// Delay ~ 1 sec.
delay(SystemCoreClock/8);

// Reset PC9
GPIOC->BSRR = GPIO_BSRR_BR_9;
// Set PC8
GPIOC->BSRR = GPIO_BSRR_BS_8;
// Delay ~ 1 sec.
delay(SystemCoreClock/8);
}
}

void delay(const int d)
{
volatile int i;

for(i=d; i>0; i--){ ; }

return;
}

• What kind of debug equipment do you have? Multimeter? Oscilloscope? Logic analyzer? – pipe May 9 '18 at 9:13
• I have a Multimeter and an Oscilloscope available – user150963 May 9 '18 at 9:17
• If you try to flash one of the example projects it doesn't work either? Can you run the code in debug mode to see what happens? – Humpawumpa May 9 '18 at 10:08