Skip to main content
Franksterb92
Senior
Aug 27, 2023 11:20 PM UTC
Solved

STM32C011J4M6 trying to use HSE as clock

ok so when i debug and step through my code the hse ready bit in the rcc-cr register sets to one but when i run it it hangs at my while loop waiting for it to set why does this happen 

This topic has been closed for replies.
Franksterb92
Franksterb92Best answer
Senior
Aug 28, 2023 7:36 PM UTC

so i put a bigger decoupling cap on the vdd vss for the mcu and it works now and i noticed that you have to clear bit 18 before setting bit 16 in the RCC->CR 

3 replies

TDK
Aug 27, 2023 11:28 PM UTC

Should set HSEBYP before or at the same time as HSEON.

HSERDY will remain clear until HSE is active. So perhaps you don't have a clock source coming in. What is your hardware? Verify clock with an oscilloscope.

Also note you can't disable HSI while it's being used as a clock source.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Franksterb92
Senior
Aug 27, 2023 11:38 PM UTC

ii just have a 20mhz crystal hooked up to pin 1 and pin 8 can i measure a crystal with occiliscope or logic analizer

Franksterb92
Franksterb92AuthorBest answer
Senior
Aug 28, 2023 7:36 PM UTC

so i put a bigger decoupling cap on the vdd vss for the mcu and it works now and i noticed that you have to clear bit 18 before setting bit 16 in the RCC->CR