This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

一小段程序在MDK里面仿真是可以的,但写进stm32就没反应了,麻烦大家帮忙看看。谢谢

下面是我的程序,我想让一个led灯亮灭交替闪烁,然后我在MDK里面仿真的时候,这个IO口电平是会交替变化的,但我把程序写进stm32的时候,它就什么反应都没有了,请问这是为什么啊?麻烦各位帮帮忙看一下程序。

谢谢你们了。

#include <sys.h>

#include "stm32f10x_rcc.h"

#include "stm32f10x_flash.h"

#include "delay.h"

int main (void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

   ErrorStatus HSEStartUpStatus;

  RCC_DeInit();

   RCC_HSEConfig(RCC_HSE_ON);

  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if(HSEStartUpStatus == SUCCESS)

{

    RCC_HCLKConfig(RCC_SYSCLK_Div1);

    RCC_PCLK2Config(RCC_HCLK_Div1);

    RCC_PCLK1Config(RCC_HCLK_Div2);

    FLASH_SetLatency(FLASH_Latency_2);

    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

    RCC_PLLCmd(ENABLE);

    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

    {

    }

}

    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

   RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;                 

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_Init(GPIOB, &GPIO_InitStructure);  

    GPIO_ResetBits(GPIOD, GPIO_Pin_2);

  delay_init();

  delay_ms(10);

  while(1)

  {

  GPIO_SetBits(GPIOD, GPIO_Pin_2);

  delay_ms(100);

  GPIO_ResetBits(GPIOD, GPIO_Pin_2);

  delay_ms(100);

  }

}

Parents Reply Children