如何通过DE2上的UART-serial发送数据

时间:2012-05-21 07:20:56

标签: c serial-port uart

当我用COM线连接两个Board-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 个答案:

答案 0 :(得分:1)

您能否更具体地说“通过Com线连接两块板-DE2”?你想要两个DE2板相互通信吗?根据上面@HansPassant提供的网站链接,您应该将DE2板连接到运行TeraTerm的PC。首先尝试此设置,并确保在TeraTerm中输入正确的COM端口设置,如网页上所述。