Skip to main content
October 14, 2022
Question

Can't get HSIRDY flag raised

Hello! I'm trying to configure TIM1 in encoder mode programming on bare metal. But problem comes up when I try to enable the HSI: the clock is enabled but it doesn't get ready. I use the #include "iostm8s003f3.h" library.

void clock_config(void){

clock_init();

CLK_ICKR_bit.HSIEN = 0x01;

while(!CLK_ICKR_bit.HSIRDY); // program gets stuck here

.

.

.

}

But when I use StdPeriph, HSIRDY rises right after I run the debug mode. Library #include "stm8s.h" 

void clock_setup(void)

{

    CLK_DeInit();

    CLK_HSECmd(DISABLE);

    CLK_LSICmd(DISABLE);

    CLK_HSICmd(ENABLE);

    while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY) == 0);

.

.

.

}

I tried to compare my code with the one that is used by STP lib and and everything looks similar. What could be missing?

    This topic has been closed for replies.