完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
写个简单的LED程序试下,发现LED不能闪烁。程序如下:
u16 i = 10000; //Systick_Config(SystemCoreClock / 1000); /* GPIOE Periph clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); /* Configure PA5 Pin output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); /* To achieve GPIO toggling maximum frequency, the following sequence is mandatory. You can monitor PE14 and PE15 on the scope to measure the output signal. If you need to fine tune this frequency, you can add more GPIO set/reset cycles to minimize more the infinite loop timing. This code needs to be compiled with high speed optimization option. */ while (1) { GPIO_SetBits(GPIOA, GPIO_Pin_5); while(i--); GPIO_ResetBits(GPIOA, GPIO_Pin_5); while(i--); } 请高手指点下。 |
|
相关推荐
10个回答
|
|
|
延时时间短了吧
|
|
|
|
|
|
本帖最后由 wambob 于 2015-1-24 16:01 编辑
延迟时间短吧,人眼能分辨的时间大于等于20MS,即50HZ以上的频率分辨不出来,延迟的短了,LED闪烁频率超过50HZ,人眼分辨不出来,看上去一直亮 |
|
|
|
|
|
你那10000 ,你输出频率是10MHZ,相当于0.1US,延迟10000*0.1=1000US=1MS
|
|
|
|
|
|
|
|
|
|
|
|
楼上回答正确
|
|
|
|
|
|
用32位整数uint32_t,把i值加大试试
|
|
|
|
|
|
i是全局变量,GPIO_SetBits(GPIOA, GPIO_Pin_5);下一句while(i--);已经把i减到0了,之后i延时就不起作用了
|
|
|
|
|
|
延时时间太短
|
|
|
|
|
|
while (1)
{ i = 10000; GPIO_SetBits(GPIOA, GPIO_Pin_5); while(i--); i = 10000; GPIO_ResetBits(GPIOA, GPIO_Pin_5); while(i--); } |
|
|
|
|
|
单独写一个亮灭函数,调整好延时才能做到闪烁
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32F405驱动DS1302时钟模块,输出时间错乱该怎么排查?
2810 浏览 2 评论
stm32f405rgt6驱动DS1302ZN出现时间错乱问题
2420 浏览 1 评论
stm32用fsmc读取ad7606采集数据,数据不变,只有开发版复位才更新数据
2288 浏览 0 评论
2404 浏览 1 评论
1643 浏览 1 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:36 , Processed in 0.919572 second(s), Total 92, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1953