📄 复件 595.c
字号:
#include "595.H"
#include <stdio.h>
#include <reg52.h>
#include <intrins.h>
#include <string.h>
sbit CS=P0^5;
sbit SCK=P0^4;
sbit SI=P0^6;
unsigned char idata outbyte=0xff;
unsigned char code charcode[18]={0x82,0xfa,0x46,0x52,0x3a,0x13,0x03,0xda,0x02,0x12,0x7f,0x1a,0x13,0x67,0x7f,0xff,0x62};//d
//*******************************
void OutByte(unsigned char b)
{
unsigned char i,j;
unsigned char bb=0x80;
//CS=0;
for(i=0;i<8;i++)
{
//SCK=0;
SI=b&bb;
bb>>=1;
_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
SCK=0;
for(j=0;j<16;j++);
SCK=1;
for(j=0;j<16;j++);
}
// CS=1;
}
/****************************************************************************/
void Delay100ms(unsigned char x)
{
unsigned char i,j;
while(x-- != 0)
{
for (j = 0;j < 114; j++)for (i = 0;i < 88; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;};
}
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$4
void SendStr_MAX7219(unsigned char *Data)
{
char i;
CS=0;
for(i=0;i<10;i++)
{ if(Data[i]==0x64)
Data[i]=16;//charcode[14];
if(Data[i]>=0x30)
Data[i]=Data[i]-0x30;
if(Data[i]==0x20)
Data[i]=15;//charcode[14];
}
OutByte(charcode[Data[3]]);
OutByte(charcode[Data[2]]);
OutByte((charcode[Data[1]])&0xfd);
OutByte(charcode[Data[0]]);
CS=1;
_nop_() ;_nop_() ;_nop_() ;
CS=0;
}
/***********************/
main()
{
unsigned char i,ms[10];
unsigned int y;
// dog=!dog;
IP=0x04;
TR0=1;
IT0=0;
EX0=0;
IT1=1;
EX1=0; //外部中断1开放
ET0=1;
ES=0 ; //串口中断打开
//init_com();
EA=0;
//i=0;
//SendStr_MAX7219("1234");
//flash_led();
// Delay100ms(10);
while(1)
{
// sprintf(ms,"12345678%2bd",i);
// i++;
/// if(i>100)i=0;
// SendStr_MAX7219(ms);
/* OutByte(charcode[1]);
OutByte(0xfa);
OutByte(0x46);
OutByte(0x52);
OutByte(0x3a);
OutByte(0x13);
OutByte(0x03);
OutByte(0xda);
OutByte(0x02);
OutByte(0x12);
OutByte(outbyte);*/
// Delay100ms(1);
Delay100ms(1);
ms[0]=1; ms[1]=2; ms[2]=3; ms[3]=4;
sprintf(ms,"0%03d",y);
SendStr_MAX7219(ms);
y++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -