1

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.

1 Answer 1

0

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.

answered Dec 26, 2024 at 4:12
Sign up to request clarification or add additional context in comments.

2 Comments

What do you mean with "flashing to RAM"? You either flash the memory or load the program to RAM.
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.