PIC18F4520的RS232輸出奇怪的現象求教?
|
||||
---|---|---|---|---|
資深會員
|
程式碼如下:
#include <p18f4520.h> #include <usart.h> unsigned char Tx_Data_Buf0=0xAA; unsigned char Tx_Data_Buf1=0xBB; unsigned char Tx_Data_Buf2=0xCC; unsigned char Tx_Data_Buf3=0xDD; void main(void) { OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH,15 ); //4xPLL, 外頻7.37MHz while(1){ while(!TXSTAbits.TRMT); TXREG=Tx_Data_Buf0; while(!TXSTAbits.TRMT); TXREG=Tx_Data_Buf1; while(!TXSTAbits.TRMT); TXREG=Tx_Data_Buf2; while(!TXSTAbits.TRMT); TXREG=Tx_Data_Buf3; Nop(); } } 結果執行第一次迴圈終端機接收的資料為 00 BB CC DD 執行第二次迴圈終端機接收的資料為 AA BB CC DD 請問上述程式哪裡出錯,為何一開始輸出不是AA
發表於: 2009/7/14 22:44
|
|||
|