📄 sendone.c
字号:
#define _SENDONE_C_
#include "reg51.h"
#include "intrins.h"
#include "sendone.h"
void SERIAL_ROUTING() interrupt 4
{
//输入程序代码
if( TI )
{
TI = 0;
if ( SendNumber )
{
SendNumber--;
SBUF = KeyValue;
}
}
}
void INIT_SERIAL()
{
SCON = 0x40;
PCON &= 0x7F;
TH1 = 0xFD;
TL1 = 0xFD;
TMOD &= 0x0F;
TMOD |= 0x20;
TR1 = 1;
IP &= 0xEF;
IE |= 0x10;
}
void InitInterrupt()
{
INIT_SERIAL();
IE |= 0x80;
LED_GREEN = LOW;
Speaker();
Delay_Nms( 20 );
Speaker();
Delay_Nms( 20 );
Speaker();
Delay_Nms( 20 );
LED_GREEN = HIGH;
}
void main()
{
unsigned char i;
unsigned char j;
InitInterrupt();
//输入程序代码
while ( 1 )
{
for ( i = 0x00; i < 0x0a; i++ )
{
SendNumber = 0x01;
KeyValue = KeyboardValue[i];
TI =1;
j = 0x00;
while( --j )
{
NOP;
NOP;
}
}
while(1);
}
}
void Speaker()
{
unsigned char i = 0x00, j = 0x00;
for (; i < 0x80; i++ )
{
SOUND = HIGH;
for ( j = 0x00; j < 0x40; j++ )
{
}
SOUND = LOW;
for ( j = 0x00; j < 0x40; j++ )
{
}
}
}
void Delay_Nms( unsigned char x )
{
unsigned char i = 0x00;
do
{
i = 0xc8;
do
{
NOP;
NOP;
NOP;
i = i - 0x01;
}while( i );
}while(x--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -