
实习生

- 积分
- 6
- 在线时间
- 4 小时
- 精华
- 0
- 注册时间
- 2019-11-25
- 最后登录
- 2019-12-9
- 专家等级
 - 结帖率
- 0%
|
程序是给的例程,是不是还需要设置什么啊,RS485接串口助手,什么数据都没有
#include <Lpc213x.H>
#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 data)
{
U1THR=data;
while((U1LSR&0x40)==0);
}
void UART1_SendStr(uint8 const *str)
{
while(1)
{
UART1_SendByte(*str++);
if(*str=='\0')
break;
}
}
int main(void)
{
PINSEL0=0x50000;
UART1_init();
while(1)
{
UART1_SendStr("welcome!\n");
DelayNS(100);
}
return(0);
}
|
|