cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f401rct6 rcc cr register

Shevshy
Associate

Hi, noob here.

I have a problem with the cr register, that's when I open the hse and Pll bite the ready register always been 0, if I need another operation? the output from the cr rigister is always value: 1000000010101101110000011. Thanks for your time. 

here is the code as followed:

let register_rcc_pllcfgr = unsafe{(RCC_BASE as *mut RW<u32>).offset(0x04 / 4)}; // GPIOC_MODER
let mut cfgr_value = unsafe{ptr::read_volatile(register_rcc_pllcfgr).read()};
cfgr_value &= !(0b1 << 22);
cfgr_value |= 0b1 << 22; // 设置为PLL_ON
cfgr_value &= !(0b111111111 << 6);
cfgr_value |= 0b010101000 << 6; //N
cfgr_value &= !(0b111111 << 0);
cfgr_value |= 0b000100 << 0;//M
cfgr_value &= !(0b11 << 16);
cfgr_value |= 0b01 << 16; //p
cfgr_value &= !(0b1111 << 24);
cfgr_value |= 0b0111 << 24; //q
unsafe{ptr::write_volatile(register_rcc_pllcfgr as *mut u32, cfgr_value)};
defmt::println!("value: {:b}",cfgr_value);

let register_rcc_cr = unsafe{(RCC_BASE as *mut RW<u32>).offset(0)}; // GPIOC_MODER
let mut cr_value =unsafe{ptr::read_volatile(register_rcc_cr).read()};
cr_value &= !(0b1 << 24); // 清除第 0 个引脚的配置
cr_value |= 0b1 << 24; // 设置为PLL_ON
cr_value &= !(0b1 << 16); // 清除第 0 个引脚的配置
cr_value |= 0b1 << 16; // 设置为HSE_ON
unsafe{ptr::write_volatile(register_rcc_cr as *mut u32, cr_value)};
//defmt::println!("value: {:b}",cr_value);
loop{defmt::println!("value: {:b}",cr_value);}
1 REPLY 1
Shevshy
Associate
et mut cfgr_value = unsafe{ptr::read_volatile(register_rcc_pllcfgr).read()};need read again