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++);
}
}
}
複製自http://www-ug.eecg.toronto.edu/msl/nios_devices/dev_rs232uart.html –