请问这段程序问题在哪里?

2019-08-13 20:27发布

//很简单的只是拉高拉低PB6,但是就是不能实现

ErrorStatus HSEStartUpStatus;

void RCC_Configuration(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/   

  /* RCC system reset(for debug purpose) */
        RCC_DeInit();

  /* Enable HSE */
        RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */
        HSEStartUpStatus = RCC_WaitForHSEStartUp();

        if(HSEStartUpStatus == SUCCESS)
        {
    /* Enable Prefetch Buffer */
                FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    /* Flash 2 wait state */
                FLASH_SetLatency(FLASH_Latency_2);

    /* HCLK = SYSCLK */
                RCC_HCLKConfig(RCC_SYSCLK_Div1);

    /* PCLK2 = HCLK */
                RCC_PCLK2Config(RCC_HCLK_Div1);

    /* PCLK1 = HCLK/2 */
                RCC_PCLK1Config(RCC_HCLK_Div2);  // 36MZH

    /* On STICE the PLL output clock is fixed to 48 MHz */
                RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

    /* Enable PLL */
                RCC_PLLCmd(ENABLE);

    /* Wait till PLL is ready */
                while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
                {
                }

    /* Select PLL as system clock source */
                RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source */
                while(RCC_GetSYSCLKSource() != 0x08)
                {
                }
        }

}

void Delay(vu32 nCount)
{
  for(; nCount!= 0;nCount--);
}


int main(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
       
        RCC_Configuration();
       
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);         
        GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;
        GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_OD;
        GPIO_Init(GPIOB,&GPIO_InitStructure);
        GPIO_ResetBits(GPIOB,GPIO_Pin_6);
       
         while(1)
         {
                        GPIO_SetBits(GPIOB,GPIO_Pin_6);
                        Delay(500);
                        GPIO_ResetBits(GPIOB,GPIO_Pin_6);
                        Delay(500);
         }
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。