标题:
封装为一个通用性数码管单片机函数,求指教哦
[打印本页]
作者:
rrrlll
时间:
2017-11-19 12:01
标题:
封装为一个通用性数码管单片机函数,求指教哦
原理图:
V}S%)WLKOB17_2(0~19)3%Y.jpg
(72.67 KB, 下载次数: 64)
下载附件
2017-11-19 11:58 上传
单片机源程序如下:
#ifndef _DEFINE_H_
#define _DEFINE_H_
#include <intrins.h>
//定义数据
unsigned char Seg_Yang_Led_Table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
//定义函数
void Delay1ms() //@11.0592MHz
{
unsigned char i, j;
_nop_();
_nop_();
_nop_();
i = 11;
j = 190;
do
{
while (--j);
} while (--i);
}
void TestSeg()
{
P2 |= 0xc0;
P0 = 0x80;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[0];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x40;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[1];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x20;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[2];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x10;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[3];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x08;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[4];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x04;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[5];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x02;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[6];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
P2 |= 0xc0;
P0 = 0x01;
P2 &= ~(0xc0);
P0 = 0xff;
P2 |= 0xe0;
P0 = Seg_Yang_Led_Table[7];
P2 &= ~(0xe0);
P0 = 0x00;
Delay1ms();
}
#endif
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1