[DONE] CFGR in STM32F4xx/hal_lld.c and maybe other STM32

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
positron
Posts: 10
Joined: Mon Aug 19, 2013 4:23 pm

[DONE] CFGR in STM32F4xx/hal_lld.c and maybe other STM32

Post by positron »

Hi,

Looking at os/hal/platforms/STM32F4xx/hal_lld.c, around line 209:

Code: Select all

  /* Other clock-related settings (dividers, MCO etc).*/
  RCC->CFGR |= STM32_MCO2PRE | STM32_MCO2SEL | STM32_MCO1PRE | STM32_MCO1SEL |
               STM32_RTCPRE | STM32_PPRE2 | STM32_PPRE1 | STM32_HPRE;


I'm wondering why ORing is used here. It relies on CFGR being 0 initially which is not the case e.g. when using a bootloader and jumping into app code or similar.

Replacing "|=" with "=" at this position seems to have no negative effect.

Also, other settings (PLLI2SCFGR,...) are assigned as well and not OR'ed.

If there was a certain reason for ORin and not assignment (glich prevention anywhere?) then it might be good idea to mention that explicitly in the code.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [TODO] CFGR in STM32F4xx/hal_lld.c and maybe other STM32

Post by Giovanni »

Hi,

I will look into this, probably it is because some reserved bits are marked as "keep at reset value".

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [TODO] CFGR in STM32F4xx/hal_lld.c and maybe other STM32

Post by Giovanni »

Hi,

I fixed this detail, also made some others initialization-related changes.

Giovanni
positron
Posts: 10
Joined: Mon Aug 19, 2013 4:23 pm

Re: [DONE] CFGR in STM32F4xx/hal_lld.c and maybe other STM32

Post by positron »

Thanks.

Just posted another bug...
Post Reply