Altera_Forum
Honored Contributor
10 years agoUART Help Please!
I already am able to read from the UART from my DE0 Board using NIOSII. I can hard-code a string and it will successfully send it to the PC Terminal. Now i got stuck trying to Write to the UART and have the board continuously read and send it back to terminal. What am i doing wrong? 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 *pinput; while(*pinput) //strings in C are zero terminated { //if room in output buffer if((*RS232_UART_DATA)&0xffff0000 ) { //then read the next character *(pinput)= *RS232_UART_DATA; } } pOutput = pinput; 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++); } } }