野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8324|回复: 2

while循环不起来

[复制链接]
发表于 2018-11-22 22:26:24 | 显示全部楼层 |阅读模式
各位老哥,这个程序的while为什么循环不起来,三个灯轮流亮一遍就停在最后一个灯了,求解!!

#include "stm32f10x.h"
void delay_us(u16 time)
{   
   u16 i=0;  
   while(time--)
   {
      i=10;  //自己定义
      while(i--) ;   
   }
}
//毫秒级的延时
void delay_ms(u16 time)
{   
   u16 i=0;  
   while(time--)
   {
      i=12000;  //自己定义
      while(i--) ;   
   }
}
int main ()
{
while(1)
{
*(unsigned int *)0x40021018 |=(1<<3);
*(unsigned int *)0x40010c00 |=((1)<<(4*5));
*(unsigned int *)0x40010c0c &=~(1<<5);
delay_ms(100);
*(unsigned int *)0x40021018 |=(1<<3);
*(unsigned int *)0x40010c00 |=((1)<<(4*1));
*(unsigned int *)0x40010c0c &=~(1<<1);
delay_ms(100);
*(unsigned int *)0x40021018 |=(1<<3);
*(unsigned int *)0x40010c00 |=((1)<<(4*0));
*(unsigned int *)0x40010c0c &=~(1<<0);
delay_ms(100);
}
}
void SystemInit (void)
{
}

回复

使用道具 举报

发表于 2018-11-23 08:35:15 | 显示全部楼层
寄存器的不方便看,你直接学后面的库函数操作,再来写一样功能的程序试试
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-11-24 11:32:41 | 显示全部楼层
好的  谢了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-22 03:23 , Processed in 0.028010 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表