📄 uart.c
字号:
#include "STC12C5410AD.h"
#include "app.h"
#include <string.h>
#include <stdio.h>
#include <intrins.h>
unsigned char UartBuffer[20];
unsigned char *pUartDebug = UartBuffer;
unsigned char UARTRECSIZE;
unsigned char uartflag=0;
extern unsigned char phone_send;
extern unsigned char phonecode[12]; //长度+存电话号码
void Uart_Done(unsigned char size);
void UartPrintOut(unsigned char *pData,unsigned char size);
extern void delay_n_ms( unsigned int n_milisecond) ;
void UartPrintOutByte(unsigned char byte);
void UART(void) interrupt 4 // UART
{
TI = 1;
if(RI)
{
RI =0;
*pUartDebug =SBUF ;
pUartDebug++;
UARTRECSIZE++;
// 重新装载数值; 设置超时时间为10MS
CCAP0L = CL + 0x00;
CCAP0H = CH + 0x24;
CCAPM0 = 0x49; // 定义为16位软件定时器
}
TI=0;
}
void UartPrintOutByte(unsigned char byte)
{
ES=0;TI=0;
enable_485_tx;
_nop_();
_nop_();
SBUF =byte;while(!TI);// 发送给PC需要的信息
TI=0;
ES=1;
enable_485_rx;
}
void UartPrintOut(unsigned char *pData,unsigned char size)
{
unsigned char i;
ES=0;TI=0;enable_485_tx;
_nop_(); _nop_();
for(i=0;i<size;i++)
{
SBUF = *pData++;while(!TI);TI=0; // 发送给PC需要的信息
}
TI=0;
ES=1;
enable_485_rx;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -