RI 裡面嵌一大堆,收一個byte送一個byte就可以了。
不需要調整任何24MHz的精準度比16.588 還好
**********************************************************************************************************
#include "ML51.h"
#include "BC26.h"
/**
* @brief UART0 Transfer and receive with interrupt subroutine.
* @param None
* @return None
* @Details Result stroage in XRAM UIDBuffer[0:8];
*/
unsigned char uart_receive_data,bufhead;
bit receiveFlag,bufOverFlag;
unsigned char temp;
void Uart0_Init(void);
void Uart0_SendChar(unsigned char Udat);
void Uart0_SendString(unsigned char *PBuf);
void USART2_IRQHandler() interrupt 4
{
if (RI)
{
RI=0;
temp=SBUF;
//nbiot_receive_process_event(temp);
//BC26_Init();
//Uart0_SendString("ATLNSOLNB\n");
Uart0_SendChar(temp);
}
if (TI)
{
TI=0; // Clear TI (Transmit Interrupt).
}
}
void Uart0_SendChar(unsigned char Udat)
{
DISABLE_UART0_INTERRUPT;
SBUF=Udat; //蔚猁楷冞腔杅擂溫揹諳杅擂遣喳
while(!TI); //脹渾楷冞俇傖
TI=0; //錨TI楷冞俇傖梓暮
ENABLE_UART0_INTERRUPT;
}
void Uart0_SendString(unsigned char *PBuf)
{
while(*PBuf!='\0') //帤善趼睫揹藺帣
{
Uart0_SendChar(*PBuf);//楷冞趼睫
PBuf++; //痄雄硌渀
}
}
void main (void)
{
MFP_P46_GPIO;
P46_PUSHPULL_MODE;
/**
For UART0 P0.5 asTXD output setting
* include uart.c in Common Setting for UART0
*/
MFP_P31_UART0_TXD; /* set P3.1 and P3.0 as Quasi mode for UART0 trasnfer */
MFP_P30_UART0_RXD;
P31_QUASI_MODE;
P30_QUASI_MODE;
UART_Open(24000000,UART0_Timer1,115200); // Open UART0 use timer1 as baudrate generate and baud rate = 115200en(24000000,UART0_Timer1,115200); // Open UART0 use timer1 as baudrate generate and baud rate = 115200
UART_Interrupt_Enable(UART0,Enable);
ENABLE_GLOBAL_INTERRUPT;
while(1)
{
//Uart0_SendString("AT\n");
Delay_ms(10000);
//BC26_Init();
Clear_Buffer();
}
}
|