N76E003UART配置代码
时间: 2024-04-30 18:20:26 浏览: 100
以下是N76E003芯片配置UART的基本代码:
```
#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
void InitialUART0_Timer1(UINT32 u32Baudrate)
{
P06_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
P07_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
SCON = 0x50; //UART0 Mode1,REN=1,TI=1
set_PCON_SMOD; //UART0 Double Rate Enable
T3CON &= 0xF8; //T3PS2=0,T3PS1=0,T3PS0=0(Prescale=1)
set_T3CON_BRCK; //UART0 baud rate clock source = Timer1
RH3 = HIBYTE(65536 - (1000000/u32Baudrate)-1); //16 MHz/(32*12*baudrate) for Baud Rate Generator value
RL3 = LOBYTE(65536 - (1000000/u32Baudrate)-1);
set_T3CON_TR3; //Trigger Timer3
}
void Send_Data_To_UART0(UINT8 c)
{
TI=1;
SBUF = c;
while(TI==1);
}
```
这个代码的作用是初始化UART0,并且可以通过Send_Data_To_UART0函数将数据发送到UART0。具体来说,这个代码会将P06和P07两个引脚配置为UART0的TX和RX引脚,然后将UART0配置为Mode1模式,并且设置波特率。最后,Send_Data_To_UART0函数会将数据发送到UART0,并且等待数据发送完成。
阅读全文