system文件夹中的delay_ms函数不能正常工作的问题

2019-07-20 23:11发布

#include "stm32f10x.h"

#include "delay.h"

void Delay(u32 count)
{
u32 i=0;
for(;i<count;i++);
}
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
       
        delay_init();
       
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|
RCC_APB2Periph_GPIOA, ENABLE); //使能 PB,PE 端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //LED0-->PB.5 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO 口速度为 50MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); //根据设定参数初始化 GPIOB.5
GPIO_SetBits(GPIOB,GPIO_Pin_5); //PB.5 输出高
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //LED1-->PE.5 端口配置, 推挽输出
GPIO_Init(GPIOA, &GPIO_InitStructure); //推挽输出 , IO 口速度为 50MHz
GPIO_SetBits(GPIOA,GPIO_Pin_5); //PE.5 输出高
while(1)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
//Delay(2000000);
        delay_ms(300);
GPIO_SetBits(GPIOB,GPIO_Pin_5);
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Delay(3000000);
        //delay_ms(600);
}
}
----------------------------------下面是问题----------------------------------
这个程序编译没有错误和警告,但是在使用proteus进行功能验证时候,使用delay(3000000)就可以正常闪烁,而使用delay_ms(300)就不正常闪烁,观察了
引脚的输出波形,当使用delay_ms(300)时候基本上输出的周期为us级别,感觉完全不正常啊,请哪位大神指点一二啊~~~

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