我想用串口2 发送一串数据,但是程序没有反应。。。。
#include "2440addr.h"
#include <stdarg.h>
#define PCLK 50000000
unsigned char a,b;//************
unsigned char LU_RU[12]={0xEf,0x01,0xff,0xff,0xff,0xff,0x01,0x00,0x03,0x01,0x00,0x05};
//串口初始化
void Uart_init()
{
rGPHCON&=~((3<<14)|(3<<12));//设置为串口功能
rGPHCON|= ((2<<14)|(2<<12)) ;//GPH2--TXD[0];GPH3--RXD[0]
rGPHUP = 0x00 ;
rULCON2|=0x03;//8位数据,1位停止位
rUCON2 = 0x05 ;//开收发
rUBRDIV2 = PCLK /9600 / 16 - 1 ;
rURXH2 = 0;
}
void Delay(unsigned char z)
{
unsigned x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
int ZWMain()
{
Uart_init() ;
while(1)
{
for(a=0;a<12;a++)
{
rUTXH0=LU_RU[a];
while(!(rUTRSTAT0&(1<<2)));
Delay(1);
}
Delay(50);
}
return 0;
}
修改代码后发现串口0可以发送,是因为咱的板子上只有串口0接了232的原因吗?还是我的代码哪里有问题? |