2023-05-21 06:04 AM
Hi everybody,
I'm using an STM8S003F3P6 on a custom board and a not original ST-Link V2 (which works fine), and I'm trying to set high the PB4 and PB5 pins. I don't know why, but it doesn't work as it should. I put my code down below.
I also wrote another program which also sets high other two pins and it work perfectly fine. Seems that everything is working fine except those two pins. I've searched for my issue on this forum but I found no solution.
The option bytes of the microcontroller are set as default. I also tried to write the code in Assembly but still doesn't work.
I've also debugged my program using STVD. At the end of the program the Output Data Register is 0x30 which means that PB4 and PB5 should be high, but that's not true (the measured voltage is around 3mV above GND value). I tried on another STM8S003F3P6 on another board (which is the copy of the first one), but the problem still exists.
Can someone help me?
Thanks,
Lorenzo
#include "stm8s.h"
main()
{
GPIO_DeInit(GPIOB);
GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_OD_HIZ_SLOW);
GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_OD_HIZ_SLOW);
GPIO_WriteHigh(GPIOB, GPIO_PIN_5);
GPIO_WriteHigh(GPIOB, GPIO_PIN_4);
//_asm("BSET $0x500F, #5");
while (1);
}
(main.c file, from STVD)
Solved! Go to Solution.
2023-05-21 08:51 AM
Aren't PB4/PB5 OPEN DRAIN in the 20-pin part?
Have an EXTERNAL pull-up
https://www.st.com/resource/en/datasheet/stm8s003f3.pdf
2023-05-21 08:45 AM
Perhaps it's not the code.
Review the HW critically.
Double check pin assignments, power supply pins, clocks, etc.
Shorts, opens, disconnected nets or islands.
If you've got a UART, perhaps add interactive code so you can query and change internal state.
What does the Input Data Register report?
2023-05-21 08:51 AM
Aren't PB4/PB5 OPEN DRAIN in the 20-pin part?
Have an EXTERNAL pull-up
https://www.st.com/resource/en/datasheet/stm8s003f3.pdf
2023-05-22 12:33 AM
You are absolutely right!
Now I understand what does "True open drain" mean.
Thanks for your help,
Lorenzo