Forum Discussion
Altera_Forum
Honored Contributor
15 years ago16550 UART to Avalon
hi, i am woring on a student project and need following information: how to connect 16550 uart to avalon interface when adding component to sopc builder. i would be proud of your respo...
Altera_Forum
Honored Contributor
15 years agoHi Cris
First of all I tested my design with an integrated sopc uart to get confidence with the following code:
void init_uart(int BAUD)
{
int divi;
divi = (50000000 / BAUD) + 0.5;
IOWR_16DIRECT(UART_BASE, 0x14, divi);
} // -- end of "init_uart()"
/* static void write_uart(char x)
*
* Send a character to the the PC
*/
void write_uart(char x)
{
unsigned long status = 0;
while((status & 0x00000040) != 0x00000040)
{
status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);
}
IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, x);
} // -- end of "write_uart()"
/* char read_uart(void)
*
* Receive a character from the PC
*/
char read_uart(void)
{
char x;
x = IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE);
return x;
} // -- end of "read_uart()"
int main(void)
{
//int iTx; // initialize the Transmitter
int i=0;
char x='a';
//char y=0x92;
char z=64;
init_uart(9600);
x=read_uart();
while (i<5)
{
write_uart(z);
x=read_uart();
z=z+1;
}
return 0;
}
It worked sucessfully. Now I wanted to test in the same way my 16550 UART to Avalon by writting/reading to/from the registries. But I don't know how to start . Please I would appreciate your advices