2013-05-31 05:53 AM
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.2013-05-31 07:07 AM
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 repetitively2013-05-31 07:09 AM
An example for the STM32L-Discovery about 3/4 way down the page.