cancel
Showing results for 
Search instead for 
Did you mean: 

PB4 doesn't work on STM8S003F3P

RomanoLorenzo
Associate II

Hi everybody, 

I'm working with STM8S003F3P6 on a custom board, using PB4 as an output. It simply does not work. It is always high. I know it is a true open drain pin, and I provided the pull-up resistor, but it still doesn't work. 

Look at this image, it's very similar to my circuit: the layout is the same, but i'm using a 3.3KOhm resistor and instead of the PIC i'm using the STM8 of course (with a supply voltage of 3.3V). If you need I can try to post the schematic.

Also the code is very simple:

 

 

GPIO_DeInit(GPIOB);
GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_OD_LOW_SLOW);
	
while(1){
	GPIO_WriteLow(GPIOB, GPIO_PIN_4);
}

 

 

I used the debug tool to check the status of the PORTB_ODR register, and its value is 0x00.

 

Any kind of help?

Thanks,

Lorenzo

3 REPLIES 3
RhSilicon
Lead

Hi,

Before starting to work with STM8, check out these tutorials, especially this one:

https://embedded-lab.com/blog/starting-stm8-microcontrollers/

More tutorials and examples:

https://github.com/rtek1000/STM8S-examples

 

I managed to use the SDCC compiler for STM8 and the Eclipse IDE, I suggest that if you can avoid using any of these high level HAL type libraries for this MCU, due to how little memory it has.

 

See here about memory:

https://github.com/platformio/platform-ststm8/issues/60

 

I believe that after seeing all the tutorials and performing the tests, one will probably even be able to help other forum users.

 

After getting everything working on the STM8, and needing free memory, if one choose to use SDCC, one can check this repository about SDCC compiler and Eclipse project, using makefile:

https://github.com/rtek1000/W1209-firmware-modified

https://github.com/rtek1000/W1209-firmware-modified/tree/master/W1209/W1209-firmware-Eclipse

 

Have a good time!

AA1
Senior III

How do you know it is always high?

Maybe pin is not connected. Try with other pin.

Maybe pin is programmed as an alternate function.

RomanoLorenzo
Associate II

Hi everybody, 

I took left the project aside for a while and now I started working on it again. Surprisingly it works perfectly, even with no changes from the problematic layout. What a strange mistery!

Anyway, thanks for your support,

Lorenzo