#include
void wait (void)
{
unsigned long i;
for (i = 0; i < 100000; )
{
i++;
}
}
/* 由串口发送一个unsigned char (8b)数据 */
void comm_send_char(unsigned char data)
{
while(!(0x020==(COMSTA0 0x020))) //当COMTX为空时TEMT(COMSTA0.5)=1,向COMTX写数据后TEMT=0
{}
COMTX = data;
}
int main (void)
{ //GPIO初始化
GP1CON = 0x00000011; // P1.0 UART SIN, P1.1 UART SOUT
//UART初始化
COMCON0 = 0x80; // Setting DLAB 访问COMDIV0和COMDIV1寄存器
COMDIV0 = 0x44; // 19200
COMDIV1 = 0x00;
COMCON0 = 0x03; // Clearing DLAB 访问COMRX和COMTX寄存器 8位长度 1停止位
GP2DAT = 0xff000000;
while (1)
{
GP2DAT ^= 0x00ff0000;
comm_send_char(0x01);
wait (); /* call wait function */
}
}
这是我的程序代码,我使用串口助手调试,收不到发送的数据,求教原因。 |