使用库函数没有任何的问题,由于空间限制,直接采用寄存器操作,结果IO输出都没有变化。
void RCC_Configuration(void)
{
/* ᅣᅳᄇ졔ᅧ뮈ᅮᅧ쨔ᅵ */
RCC->CR |= (uint32_t)0x00000001;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts and clear pending bits */
RCC->CIR = 0x009F0000;
/* Vector Table Relocation in Internal FLASH. */
SCB->VTOR = FLASH_BASE;
while((RCC->CR & 0x02) == 0);
//AHB Clock = SYSCLK , APB1 = SYSCLK , APB2 = SYSCLK/2
//│ᅱᅢPLLᅧ뮈ᅮᅯᄡᄐᄚ12ᄆᄊ
RCC->CFGR = 0x282000;
//ᅧ쨔ᅵPLL
RCC->CR |= 0x01000000;
while((RCC->CR & 0x02000000) != 0x02000000);
//│ᅱᅢᅬ솨뼈뮈ᅮᆪᄄSYSCLKᆪᄅ │ᅱᅢPLLᅫᆰᅬ솨뼈뮈ᅮᅯᄡ
RCC->CFGR |= 0x02;
while((RCC->CFGR & 0x0C) != 0x08);
/* Enable peripheral clocks ------------------------------------------------*/
/* Enable USART2, TIM2,clocks */
RCC->APB1ENR = RCC_APB1Periph_TIM2 | RCC_APB1Periph_USART2;
/* Enable GPIOA clock */
RCC->APB2ENR = RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD;
}
void PowerOnInitIOPort(void)
{
//==========================================
//USB 电源控制
/* USART2 使用IO端口配置 */
RCC->APB2RSTR |= RCC_APB2Periph_GPIOA;
RCC->APB2RSTR &= ~RCC_APB2Periph_GPIOA;
GPIOA->CRL = 0x4900;
GPIOA->CRH = 0x1;
GPIOA->ODR = 0;
//GPS_ON
RCC->APB2RSTR |= RCC_APB2Periph_GPIOB;
RCC->APB2RSTR &= ~RCC_APB2Periph_GPIOB;
GPIOB->CRL = 0x100;
GPIOB->ODR = 0;
//==========================================
//CORE_ON,CORE_RST
RCC->APB2RSTR |= RCC_APB2Periph_GPIOD;
RCC->APB2RSTR &= ~RCC_APB2Periph_GPIOD;
GPIOD->CRL = 0x11;
GPIOD->ODR = 0;
}
|