2012-05-21 46 views
1

當我使用COM線連接兩個Board-DE2時,此代碼不通過UART發送數據。我不明白它爲什麼不運行。怎麼了?如何通過DE2上的UART串行發送數據

#define RS232_UART_DATA ((volatile int*) 0x10001010) 
#define RS232_UART_CONTROL ((volatile int*) (0x10001010+4)) 

int main() 
{ 
    unsigned char hwld[] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'}; 
    unsigned char *pOutput; 

    pOutput = hwld; 
    while(*pOutput) //strings in C are zero terminated 
    { 
     //if room in output buffer 
     if((*RS232_UART_CONTROL)&0xffff0000 ) 
     { 
      //then write the next character 
      *RS232_UART_DATA = (*pOutput++); 
     } 
    } 
} 
+1

複製自http://www-ug.eecg.toronto.edu/msl/nios_devices/dev_rs232uart.html –

回答

1

你能更具體地關於「通過Com線連接兩個Board-DE2」嗎?你想要兩塊DE2板互相通信嗎?根據上面的@HansPassant提供的網頁鏈接,您應該將DE2 Board連接到運行TeraTerm的PC。請先嚐試此設置,並確保您在網頁上提到的TeraTerm中輸入正確的COM端口設置。