2022-09-06 06:47 AM
Hello, I am studying the STM8S208RB MCU and the SPL. I am using STVD and COSMIC, and the Nucleo-8S208RB board for testing.
The below code should configure port GPIOC Pin5 and set it to high and stay high. However, LED2 turns on for only a short moment, not permanently. The STM8 Nucleo-64 board has the User LED2 on GPIO Port C, Pin 5.
What is wrong with the code? Thank you!
/* Configure the LED2 GPIO */
/* Reset the GPIO Pin in CR2 register */
LED2_GPIO_PORT->CR2 &= (uint8_t)(~(LED2_GPIO_PIN));
/* Output mode selection */
LED2_GPIO_PORT->ODR |= (uint8_t)LED2_GPIO_PIN; /* High level output */
LED2_GPIO_PORT->DDR |= (uint8_t)LED2_GPIO_PIN; /* Output mode */
LED2_GPIO_PORT->CR1 |= (uint8_t)LED2_GPIO_PIN; /* Push-Pull output mode */
LED2_GPIO_PORT->CR2 |= (uint8_t)LED2_GPIO_PIN; /* 10 MHz fast output */
/* Turn On LED2 */
LED2_GPIO_PORT->ODR |= (uint8_t)LED2_GPIO_PIN;
Solved! Go to Solution.
2022-09-06 09:06 PM
Hi Tesla, thank you for your quick response. The main.c source file is attached. please have a look. This is the code example that comes with the ST Application Note AN5178. ONly SPL function write to the output, I believe.
I made one change in Line 43 to accommodate the Nucleo-8S208RB:
#define LEDS_PORT (GPIOC) //for Nucleo-8S208RB
Thank you for your feedback!
-km
2022-09-08 09:23 PM
This issue is resolved with a workaround for ST Visual Programmer (STVP). I assume e better solution exists.
Option 1: Program the Nucleo-8S208RB with the STVP. Close STVP: the Nucleo's COM LED turns red and the application starts running.
Option 2: Program the Nucleo-8S208RB with the STVP. Open the Configuration window (see below): the COM LED turns ghreen. Click OK: the application start to run.