单片机,数码管扫描问题~为啥我的貌似就一次循环?然后就一直显示0了?

[复制链接]
查看11 | 回复5 | 2012-11-2 13:52:54 | 显示全部楼层 |阅读模式
变量i的数据类型定义错误,uchar最大只有255,不能达到1300,这个直接溢出了,一直在for中死循环,将uchar i 改成uint i 另外delay(50000000);中的50000000太大了,uint最大只有65535....
回复

使用道具 举报

千问 | 2012-11-2 13:52:54 | 显示全部楼层
#include
// 试试#includechar code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};void delay(unsigned int time){ unsigned char cycle;...
回复

使用道具 举报

千问 | 2012-11-2 13:52:54 | 显示全部楼层
#define uchar unsigned char#define uint unsigned int#define ulong unsigned longuchar code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};void delay(ulong x){...
回复

使用道具 举报

千问 | 2012-11-2 13:52:54 | 显示全部楼层
void delay(uint x){uchar i;while(x--)for(i=0;i<1300;i++);}i定义的是uchar,for里边比较的时候,;i<1300
溢出了,i就8位哪能到1300????...
回复

使用道具 举报

千问 | 2012-11-2 13:52:54 | 显示全部楼层
扫描速度问题。...
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行