📄 disp.c
字号:
#include"stc89c5x.h"
#define uchar unsigned char
#define uint unsigned int
sbit SCLK_LED = P4^0; //595时钟 新卡大数码管
sbit LATCH_LED = P4^3; //595锁存,高有效
sbit IO_LED = P4^1; //LED 数据输入口
uchar LED_TAB[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x00};
void init();
void MsDelay(uint);
void Disp_LED();
void Send_Byte(uchar S_Byte);
main()
{
init();
while(1)
{
Disp_LED();
}
}
//***************************************
//**********单片机初始化函数*************
//***************************************
void init()
{
MsDelay(50);
LATCH_LED = 0;
SCLK_LED = 0;
TMOD = 0x21; //定时器1方式2,作波特率发生器,定时器0方式1,16位定时器
SCON = 0x50; //SET COMM. IN MODE1 设置串行口方式1,允许接收,10位异步收发
PCON = 0x00;
IE = 0x90; //开总中断及串行中断
TH0 = 0x72; //TIM 定时器0的初值,约20MS定时
TL0 = 0x28; //TIM
TH1 = 0xFA; //SET T0 IN MODE1,AS A TIMER. 定时器1初值
TL1 = 0xFA; //SET 9600BPS AT 22.1184MHz.
//TR1 = 1; //启动定时器
//TR0 = 1;
}
/**********************************
***********送显示的函数************
***********************************/
void Disp_LED() //i决定了发送多少个字节的数据 //恭调试用
{
uchar i;
uint j;
LATCH_LED = 0;
for(i=0;i<=10;i++)
{
for(j=0;j<1000;j++)
{
Send_Byte(LED_TAB[i]);
LATCH_LED = 1;
}
LATCH_LED = 0;
}
}
/********************************
**********发送一字节的函数*******
*********************************/
void Send_Byte(uchar S_Byte)
{
uchar i;
//LATCH_LED = 0;
for(i=0;i<8;i++)
{
SCLK_LED = 0;
IO_LED = 0;
if(S_Byte&0x80)
IO_LED = 1;
SCLK_LED = 1;
S_Byte <<= 1;
}
SCLK_LED = 0;
//LATCH_LED = 1;
//MsDelay(1000);
}
/**********************************
*******1毫秒延时函数****************
***********************************/
void MsDelay(uint Delay)
{
uchar i;
for(;Delay>0;Delay--)
for(i=124;i>0;i--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -