栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

数码管显示时钟样式(编译过程中出现了C307报错,已解决)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数码管显示时钟样式(编译过程中出现了C307报错,已解决)

根据欧浩源老师的数码管动态显示源码改编,基于IAP15K61S2开发。

原本是0xbf的显示为-,但是显示成其他的了,所以改成0x3f才能显示-。

#include 
#define uchar unsigned char

uchar miao=49;
uchar fen=59;
uchar shi=23;
uchar  ma[18]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x3f,0xbf};

void Delay(unsigned int t)
 {
 while(t--);
 }
 
  void Delay2(unsigned int J)
{
 while(J--)
	{
	smgstaic();
	}
}

void inh(unsigned char n)
{
switch(n)
{
  case 4:
		P2=(P2=0x1f)|0x80;
	break;
		case 5:
			P2=(P2=0x1f)|0xa0;
		break; 
			case 6:
				P2=(P2=0x1f)|0xc0;
			break;
				case 7:
					P2=(P2=0x1f)|0xe0;
				break;
} 
}

void smg_display(unsigned char dat,unsigned char pos )
{
inh(6);
P0=0x01<59)
	{
	miao=0;
	fen++;
		if(fen>59)
		{fen=0;
		shi++;
			if(shi>23)
			{
			shi=0;
			}
		}
	}
	Delay2(200);
} 
}

以上代码会出现Delay2的C231的报错,常见的改错方式为添加一个宏定义或者将Delay2整体移动到调用Delay2的函数之后。

如果添加宏定义将会出现C231的报错以及C307的报错,仔细检查后原来是宏定义()里的unsigned char J没有写进去,写进去后,又出现了C304报错,最后将宏定义的部分写为以下形式

#define void Delay2(    unsigned int J);

解决了报错问题,但是有警告。

如果采用整体后移那么就是以下形式

#include 
#define uchar unsigned char

uchar miao=49;
uchar fen=59;
uchar shi=23;
uchar  ma[18]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x3f,0xbf};

void Delay(unsigned int t)
 {
 while(t--);
 }
 

void inh(unsigned char n)
{
switch(n)
{
  case 4:
		P2=(P2=0x1f)|0x80;
	break;
		case 5:
			P2=(P2=0x1f)|0xa0;
		break; 
			case 6:
				P2=(P2=0x1f)|0xc0;
			break;
				case 7:
					P2=(P2=0x1f)|0xe0;
				break;
} 
}

void smg_display(unsigned char dat,unsigned char pos )
{
inh(6);
P0=0x01<59)
	{
	miao=0;
	fen++;
		if(fen>59)
		{fen=0;
		shi++;
			if(shi>23)
			{
			shi=0;
			}
		}
	}
	Delay2(200);
} 

0报错,0警告。每20min有1min误差(毕竟没有时钟,原理还是C语言计数程序)。有需要改正的地方请指出。

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1018120.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号