Why do I get an Error after stetting the PLL as System clock input?
This is the code:
#include <stm32f4xx.h>
void main(void)
{
//Set up PA5(LED)
RCC -> AHB1ENR |= 0x00000001; //enables clock for GPO PA
GPIOA -> MODER |= 0x00000400; //PA Pin 5 as GPO
GPIOA -> OTYPER |= 0x00000000; //PA Pin 5 as Push/Pull
GPIOA -> OSPEEDR |= 0x00000C00; //PA Pin 5 as High speed
GPIOA -> PUPDR |= 0x00000000; //PA Pin 5 as No pull-up/down
//clock at 180mhz
RCC -> PLLCFGR &= ~(1<<22); //set HSI as PLL input
RCC -> PLLCFGR |= (1<<4); //set PLLM prescaler to 16
RCC -> PLLCFGR |= ((1<<9) | (1<<11) | (1<<12) | (1<<14)); //PLL multimpiler *360
RCC -> CFGR |= ((1<<10) | (1<<12)); //AHB1 presclaer = /4
RCC -> CFGR |= (1<<12); //AHB2 prescaler = /2
RCC -> CR |= (1<<24); //enables PLL
RCC -> CFGR |= (1<<1); //sets PLL as main clock input
while(1)
{
//main loop
GPIOA -> BSRR = (1<<5);
GPIOA -> BSRR = (1<<21);
}
}
Once I start the code and it gets to RCC -> CFGR |= (1<<1); I get an error. I do not see why? Can someone please explain me? I am using the Segger IDE. All code is written in C. It should configure the Main PLL to get the freq. from the HSI and get it to 180MHz. Once the code gets to the point where it changes the system clock source from HSI to PLL _P it crashed:
Loading target script file STM32F4xx_Target.js
Preparing target for download
Executing Reset script Reset();
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading ‘blink.elf’ to J-Link
Programming 1.1 KB of addresses 08000000 — 080004c7
J-Link: Flash download: Bank 0 @ 0x08000000: 1 range affected (16384 bytes)
J-Link: Flash download: Total time needed: 0.525s (Prepare: 0.066s, Compare: 0.041s, Erase: 0.374s, Program: 0.026s, Verify: 0.008s, Restore: 0.008s)
Download successful
T-bit of XPSR is 0 but should be 1. Changed to 1.
Stopped by vector catch
Error reading from memory
