Forum Discussion
Altera_Forum
Honored Contributor
10 years ago --- Quote Start --- zikmir, you posted several uart related questions in the past few days. Here is a very useful thread on how to use UART to communicate with external devices such as PC: http://www.alteraforum.com/forum/showthread.php?t=17224 I've used this code successfully to talk to the PC. --- Quote End --- Thanks for your reply, my issue is not on coding, and i am not familiar with the methods you have used. My entire question is trying to understand how the hardware it self has to be configured, as of the DATA Register and Control Register. I am already able to print any characters to the Terminal(Sending from UART to PC) but i really need some help on the opposite direction. If you may help me with this specific issue i would be glad than using some one else code. Kindly if you or any one can guide me on how to read the UART. Here is my code: # include <stdio.h># define RS232_UART_DATA ((volatile int*) 0x10001010)# define RS232_UART_CONTROL ((volatile int*) (0x10001010+4)) int main() { unsigned char *pOutput; unsigned char mask; while(1) //strings in C are zero terminated { mask = ((*RS232_UART_DATA)&0xFFFF0000); // mask incoming UART if (mask!=0){ pOutput=((*RS232_UART_DATA)&0x0000ff); } if((*RS232_UART_CONTROL)&0xff0000 ){ *RS232_UART_DATA = (*pOutput); } //output back to PC Terminal } }