Search code examples
cembedstmstm8

STM8L152R8 board LED not turning on


I have been working with the STM8L152R8 development board, but it does not seem to let me blink LD2 (which should be mapped to PB5) or really change any value at all. Here is my code. Thanks!

#include <stdint.h>

#define PB_ODR  *(volatile uint8_t *)0x5005
#define PB_DDR  *(volatile uint8_t *)0x5007
#define PB_CR1  *(volatile uint8_t *)0x5008
#define PB_CR2  *(volatile uint8_t *)0x5009

#define CLK_DIVR    *(volatile uint8_t *)0x50c0

unsigned char i;

void main(void)
{
    CLK_DIVR = 0x00; // Set the frequency to 16 MHz
    PB_ODR = 0;
    PB_DDR = 1 << 5;
    PB_CR1 = 1 << 5;
    
    while(1)
    {
        PB_ODR ^= 1 << 5;
        for(i = 0; i < 15000; i++){}
    }
}

I have also tried setting the registers to 0xFF to see if anything turns on, but I'm not getting any voltage out.


Solution

  • I was not flashing the program correctly, a lot of the tutorials I used I think were fine. I needed to be flashing it to RAM instead of programming the tab.