cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in GPIO_WriteBit() function in STM8L Library???

buzzbuxx
Associate
Posted on July 29, 2016 at 18:11

I have been using the GPIO_WriteBit() function to set/reset pins, but found it not working. The same function by register worked fine.

Example:

GPIO_WriteBit(GPIOB, GPIO_Pin_4, RESET); // this does not work!?

GPIOB->ODR &= 0xef;   // this is ok.

I check the source code of GPIO_WriteBit() and suspect there is a bug. Specifically, when RESETing, the function calls

    

ClrBit(GPIOx->ODR, GPIO_Pin);

whereas macro ClrBit is defined as

    

&sharpdefine ClrBit(VAR,Place)    ( (VAR) &= (uint8_t)((uint8_t)((uint8_t)1<<(uint8_t)(Place))^(uint8_t)0xFF) )

It seems that it intends to do ChlrBit(GPIOB, 4) but instead does ClrBit(GPIOB, GPIO_Pin_4), which is not working.

Can somebody confirm this?

#std_lib #stm8l
1 REPLY 1
Pavel A.
Evangelist III
Posted on October 25, 2017 at 23:52

Confirmed.... better late than never. Documentation error for the 2nd parameter.

-p.