Support for HSEBYP

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Support for HSEBYP

Post by mobyfab »

Hi,

Could someone add support for HSEBYP?

I want to connect an external clock to the MCU, and there's no clean way to do so.

basically

in mcuconf.h:

Code: Select all

#define STM32_HSE_BYPASS  TRUE (should depend on HSE_ENABLED)


in hal_lld.c:

Code: Select all

#if STM32_HSE_ENABLED
   #if STM32_HSE_BYPASS
     /* HSE Bypass.*/
     RCC->CR |= RCC_CR_HSEBYP;
   #endif
  /* HSE activation.*/
  RCC->CR |= RCC_CR_HSEON;
  while (!(RCC->CR & RCC_CR_HSERDY))
    ;                                       /* Waits until HSE is stable.   */
#endif


HSEBYP can only be written when HSE is not enabled yet, so I put it before.

Bit 18 HSEBYP: External high-speed clock bypass
Set and cleared by software to bypass the oscillator with an external clock. The external
clock must be enabled with the HSEON bit set, to be used by the device. The HSEBYP bit
can be written only if the HSE oscillator is disabled.
0: external 4-16 MHz oscillator not bypassed
1: external 4-16 MHz oscillator bypassed with external clock


STM32_HSE_BYPASS is already defined.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Support for HSEBYP

Post by Giovanni »

Hi,

I added it but, IMO, you need to define STM32_HSE_BYPASS in your board.h not mcuconf.h, it is a board design related setting not an application setting.

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: Support for HSEBYP

Post by mobyfab »

Indeed that sounds more appropriate.

Thanks :)
Post Reply