新手上路
- 积分
- 28
- 金钱
- 28
- 注册时间
- 2017-7-16
- 在线时间
- 6 小时
|
1金钱
@正点原子- int systime_int()
- {
- int countnumber=40000;
-
- RCC->CR |=(uint32_t)(1<<16);
- do
- {
- countnumber--;
- }while((!(RCC->CR & (uint32_t)0x20000))|| countnumber );
- if(RCC->CR & (uint32_t)0x20000)
- {
- //FLASH_SetLatency(FLASH_Latency_5);
- RCC->PLLCFGR |=(uint32_t)(1<<3);//pllm
- RCC->PLLCFGR |=(uint32_t)(0x150<<6);//plln
- RCC->PLLCFGR |=(uint32_t)(0x40<<16);//pllp
- RCC->PLLCFGR &=(uint32_t)(4<<24);//pllq
-
- RCC->CFGR |=(uint32_t)(0x0<<4);//ahb
- RCC->CFGR |=(uint32_t)(1<<15);//apb2
- RCC->CFGR |=(uint32_t)(1<<12);//apb1
- RCC->CFGR |=(uint32_t)(1<<10);//apb1
- RCC->CFGR |=(uint32_t)(1<<19);
- RCC->CFGR |=1<<1;
- }
- else
- {
- return 0x07;//外部震荡器使能失败;
- }
- RCC->CR|=(uint32_t)(1<<24);
- countnumber=40000;
- do
- {
- countnumber--;
-
- }while((!(RCC->CR & 0x2000000)) || countnumber );
- countnumber=40000;
- do
- {
- countnumber--;
- }while(!(RCC->CFGR &(uint32_t)0x08) || countnumber);
- if(RCC->CFGR &(uint32_t)0x08)
- {
- FLASH_SetLatency(FLASH_Latency_5);
- return 0x01;//pll成功
- }
- else
- {
- return 0x02;//pll失败
- }
- }
复制代码 代码如上,用标准库写的,gpio驱动不起来
经过调试rcc->cr = 0x03038183
rcc->pllcfgr =0x04405408
rcc->cfgr= 0x0008940A
main.c如下
- int main()
- {
-
- GPIO_InitTypeDef *hgpiog;
- hgpiog->GPIO_Pin=GPIO_Pin_13;
- hgpiog->GPIO_Mode=GPIO_Mode_OUT;
- hgpiog->GPIO_OType=GPIO_OType_PP;
- hgpiog->GPIO_PuPd=GPIO_PuPd_UP;
- hgpiog->GPIO_Speed=GPIO_Speed_100MHz;
-
- systime_int();
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG,ENABLE);
- SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
-
- GPIO_DeInit(GPIOG);
- //RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
- GPIO_Init(GPIOG,hgpiog);
- //USART_Init(USART1,huart);
- while(1)
- {
- //GPIO_WriteBit(GPIOG,GPIO_Pin_13,Bit_SET);
- GPIO_WriteBit(GPIOG,GPIO_Pin_13,Bit_RESET);
- }
-
- }
复制代码 求大佬看一下,啥地方出问题了
|
|