该程序是一个例程。我还需要设置什么吗?RS485 连接串口助手,无数据
#include
#define UART_BPS 9600
#define FPCLK 12000000
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
void DelayNS (uint32 dly)
{
uint32 i;
for (; dly> 0; dly--)
for (i = 0; i <50000; i++);
}
void UART1_init (void)
{
uint16 Fdiv;
U1LCR = 0x83;
Fdiv = (FPCLK / 16) / UART_BPS;
U1DLM = Fdiv / 256;
U1DLL = Fdiv% 256;
U1LCR = 0x03;
}
void UART1_SendByte(uint8 数据)
{
U1THR = 数据;
而 ((U1LSR & 0x40) == 0);
}
void UART1_SendStr (uint8 const * str)
{
while (1)
{
UART1_SendByte (* str ++);
如果 (* str == \'\\ 0\')
中断;
}
}
int main (void)
{
PINSEL0 = 0x50000;
UART1_init();
while (1)
{
UART1_SendStr(\"欢迎!\\N\");
延迟NS(100);
}
返回(0);
}