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 12:07 PM
Not seeing the code.
Attach main.c to the bottom of the post, see Paper Clip Icon below posting window.
How is this all connected? Avoid using Hubs or Docking Stations with ST-LINK / NUCLEO, use quality cables.
Does the STM8 have some kind of debugger? Can you drive that?
How about outputting info via UART at the same time and blinking LED?
2022-09-06 07:52 AM
Can you clarify what is LED2_GPIO_PIN?
LED2_GPIO_PORT->ODR |= (uint8_t)LED2_GPIO_PIN;
But something is causing the device to a hard fault (Maybe), use a debugger and set breakpoint and see what is happening!
2022-09-06 07:54 AM
Thanks for your response! The STM8 Nucleo-64 board has the User LED2 on GPIO Port C, Pin 5.
2022-09-06 08:37 AM
If it went to a hard fault, then the light will be on for the entire time. So my answer is wrong!
2022-09-06 08:46 AM
>>What is wrong with the code?
Perhaps it's not an issue with the code you've shown?
2022-09-06 08:49 AM
Update: the example code for ST Application Note AN5178 exhibits the same issue, therefore my source code above may not be the root cause. I am wondering if the ST Visual Programmer is not setup right? The LED2 flashes twice, first during programming, and the second time during code verification. But the following while(1) loop should flash the LED, and that is not happening. Any thoughts?
2022-09-06 08:49 AM
Thank you. Please see my latest update below.
2022-09-06 12:07 PM
Not seeing the code.
Attach main.c to the bottom of the post, see Paper Clip Icon below posting window.
How is this all connected? Avoid using Hubs or Docking Stations with ST-LINK / NUCLEO, use quality cables.
Does the STM8 have some kind of debugger? Can you drive that?
How about outputting info via UART at the same time and blinking LED?
2022-09-06 12:45 PM
Hi Tesla, thanks for your quick response.
Connections:
* ST_Tools on Windows10 desktop -> ST-Link USB driver -> USB data cable -> ST-Link Debugger on Nucleo-8S208RB -> SWIM -> MCU.
Status update (success):
* After loading the .s19 firmware file with STVP the Nucleo's COM LED is green,
LED2 dos not blink.
* Re-open the STVP window 'Configure ST Visual Programmer' (screenshot attached).
* Click OK. The COM LED turns read and the User LED starts blinking!
Question:
* It seems that setting the STVP configuration (again) disconnects the Nucleo-64 board
and starts the program. Is that correct?
* What happens 'behind the scenes' when setting the STVP configuration.
2022-09-06 06:40 PM
Are you setting level before output? How many codelines from different functions write on the gpio regusters? Anyone under interrupt? Read modify write corruption?