cancel
Showing results for 
Search instead for 
Did you mean: 

Problems blinking blue LED

deivad_ibz
Associate
Posted on May 31, 2013 at 14:53

Hi all!

I'm a newbie and I have problems with my STM32L-Discovery. I'm trying to do the simplest possible program: make the blue LED in PB6 output blink.

This is the code I've made:

#include <stdio.h>                           /* standard I/O .h-file          */

#include <stm32f10x.h>                       /* STM32F10x definitions         */

int main()

{

RCC->APB2ENR |= (1UL << 3);

GPIOB->ODR   &= 0x00000000;               /* switch off LEDs               */

GPIOB->ODR   |= 0x00000040;                                /* switch on LEDs               */

GPIOB->CRL     |= 0x05000000;

while (1){}

}

I compile it, and no errors are shown, but nothing happens in the board. I'm using Keil uVision.
2 REPLIES 2
Posted on May 31, 2013 at 16:07

Decide if you have an L1xx part (STM32L-Discovery) or an F1xx part (STM32VL-Discovery), they are not the same.

Use the FW Library for the right part. Writing code at a register level requires a far better grasp of things.

Things won't blink unless you sit in a loop alternating the settings, with a delay between them so you can perceive the change in state.

Compiler's simply check for correct syntax, you can compile gibberish without error, it says nothing about the functional correctness.

You must enable to clock to the GPIO bank

You must configure the GPIO as a PP output, etc

You can then drive HIGH and LOW states repetitively

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..