程序如下:
while (1)
{
/* Loop forever */
if ( UART0Count != 0 )
{
U0IER = IER_THRE | IER_RLS; /* Disable RBR */
UARTSend( 0, (BYTE*)UART0Buffer, UART0Count );
UART0Count = 0;
U0IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */
LCD_gotoxy(1,1);
LCD_puts(UART0Buffer);
}
串口程序1
void UARTSend( DWORD portNum, BYTE *BufferPtr, DWORD Length )
{
WORD i=0;
if ( portNum == 0 )
{
while ( Length != 0 )
{
/* THRE status, contain valid data */
while ( !(UART0TxEmpty & 0x01) );
U0THR = BufferPtr[i];
UART0TxEmpty = 0; /* not empty in the THR until it shifts out */
//BufferPtr++;
Length--;
i++;
}
}
else
{
while ( Length != 0 )
{
/* THRE status, contain valid data */
while ( !(UART1TxEmpty & 0x01) );
U1THR = BufferPtr[i];
UART1TxEmpty = 0; /* not empty in the THR until it shifts out */
//BufferPtr++;
Length--;
i++;
}
}
return;
}
串口程序2
void UARTSend( DWORD portNum, BYTE *BufferPtr, DWORD Length )
{
WORD i=0;
if ( portNum == 0 )
{
while ( Length != 0 )
{
/* THRE status, contain valid data */
while ( !(UART0TxEmpty & 0x01) );
U0THR = *BufferPtr;
UART0TxEmpty = 0; /* not empty in the THR until it shifts out */
BufferPtr++;
Length--;
}
}
else
{
while ( Length != 0 )
{
/* THRE status, contain valid data */
while ( !(UART1TxEmpty & 0x01) );
U1THR = *BufferPtr;
UART1TxEmpty = 0; /* not empty in the THR until it shifts out */
BufferPtr++;
Length--;
}
}
return;
}
上面的lcd_puts(char*)
为1602的字符形液晶显示器;
我碰到的问题是,我想串口写段数据,然后在用串口发回pc机,从lcd上显示刚才的字符;
可是在单步调试能正常显示,全速运行后只能显示1个字符,就是最后一个,谁碰到国这个问题?给解释下 |