⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 595.c

📁 矿工定位系统单端
💻 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;
sbit wdg		= P1^0;	
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)
  { wdg=!wdg;
 	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_() ; _nop_() ;_nop_() ;_nop_() ; _nop_() ;_nop_() ;_nop_() ; _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)
 { P0=0X00;
  P0=0X02;
P0=0X04; 
P0=0X08; 
//   sprintf(ms,"12345678%2bd",i);
//   i++;
///   if(i>100)i=0;
//  SendStr_MAX7219(ms);
 
  /*OutByte(charcode[1]);
   Delay100ms(20); 
  OutByte(0xfa);
   Delay100ms(20); 
  OutByte(0x46);
 Delay100ms(20); 
  OutByte(0x52);
  Delay100ms(20); 
 // Delay100ms(1); 
  wdg=!wdg;
   Delay100ms(1); 
  //sprintf(ms,"1234");
//SendStr_MAX7219(ms);
 
 y++;*/

 
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -