STM8S HSI clock init bug/typo

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
cwia
Posts: 4
Joined: Mon Feb 20, 2012 1:22 pm

STM8S HSI clock init bug/typo

Post by cwia »

It seems the HSI clock initialization is not correct in os\hal\platforms\STM8S\hal_lld.c

Code: Select all

  /* Makes sure that HSI is stable before proceeding.*/
  CLK->ICKR |= CLK_ICKR_HSIRDY;
  while ((CLK->ICKR & CLK_ICKR_HSIRDY) == 0)
    ;

The ICKR should be set to CLK_ICKR_HSIEN. However, the code might not be needed at all (?), because the HSI is enabled by default at startup and the HSI RC output clock is not released until this bit is set by hardware (and there has been code already executed - stack init etc.)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM8S HSI clock init bug/typo

Post by Giovanni »

Thanks for finding, it will be fixed in next version.

Like you pointed out the code probably is not required but it is safer to assume the state is not 100% reliable, especially when the code is being debugged.

Giovanni
Post Reply