2023-08-22 12:08 AM
Here i am trying to set PLL as the system clock using HSI of 16MHz for STM32F401RE development board, but the moment i enable the "SET PLL as system clock" bit, the system gets reset. What can be the reason for this. I am trying to achieve 70 MHz of frequency.
Below is the code for the same.
2023-08-22 12:57 AM - edited 2023-08-22 12:59 AM
I use the IDE to generate these types of codes automatically.
I don't know if it can help in your case, but I found these videos about advanced debugging:
STM32CubeIDE Advanced Debug Features
https://youtube.com/playlist?list=PLnMKNibPkDnEDEsV7IBXNvg7oNn3MfRd6
There are also videos about the IDE:
https://www.youtube.com/@stmicroelectronics/search?query=STM32CubeIDE
There is a video search box in the profile:
2023-08-22 05:15 AM
After turning on PLL with (note RCC_CR_PLLON is easier to read than 1<<24)
RCC->CR |= RCC_CR_PLLON;
you need to wait for the PLL to lock and show it is ready
while ((RCC->CR & RCC_CR_PLLRDY) == 0)
{ ; }
before changing clock mode. The time to lock is only something like 300us, but that's an eternity to a microcontroller.
2023-08-22 06:42 AM
Are you setting wait states appropriately before increasing the system clock?
2023-08-23 01:50 AM
Thanks for reply, I tried that as well, waiting until PLL is ready then only switching the system clock from HSI to PLL but still my code is jumping to infinite loop or sometimes giving error of address not found. Is this the correct of setting PLL clock?
2023-08-23 02:30 AM
Nucleo boards do not have the embedded crystal and capacitors for the MCU. The MCO from the integrated debugger is used as the HSI. For use with a crystal, it is necessary to first solder it, including auxiliary capacitors, and disconnect the clock supply from the debugger by desoldering the jumper.
2023-08-23 02:51 AM
True but i am using HSI, internal 16MHz frequency not the HSE
2023-08-23 02:53 AM - edited 2023-08-23 02:54 AM
I have kept while loop until the HSIRDY and PLLRDY bits are SET to 1. Even after that the moment i run my code in debug mode, it comes out of debugging.
2023-08-23 03:43 AM
Hello @DJ1,
Have you tried using CubeMX? By default, using Nucleo-F401RE SYSCLK is configured to reach 84MHz.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-08-23 03:45 AM
Oh, sorry. Stupid oversight.