openwch / ch32v003

CH32V003 is an ultra-cheap RISC-V MCU with 2KB SRAM, 16KB flash, and up to 18 GPIOs that sells for under $0.10
373 stars 56 forks source link

IWDG_Enable() bug #33

Open alfersi opened 7 months ago

alfersi commented 7 months ago

IWDG_Enable in ch32v00x_iwdg.c of the peripheral library has a bug while checking if the bit LSYRDY of the RSTSCKR register is set by waiting endlessly for it to be set with a condition impossible to meet:

while ((RCC->RSTSCKR)|(0x2)!= SET);

The correct way should be:

while ((RCC->RSTSCKR & RCC_LSIRDY)!= RCC_LSIRDY);

blu006 commented 5 months ago

I also noticed this bug when the compiler pointed me to it after I turned on -Wall