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.
THe link to the manual is here: http://www.st.com/content/ccc/resource/technical/document/user_manual/30/ae/6e/54/d3/b6/46/17/DM00050135.pdf/files/DM00050135.pdf/jcr:content/translations/en.DM00050135.pdf
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;
}