Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Neek - Uart

im just a newbie in FPGA programming

just want to ask how to add a UART (rs232) into the hardware design.

I already tried to add it on SOPC builder and generate

and recompile it on quartus.

unfortunately its not working.

i am using a simple code transmitting a character (NEEK is connected on my PC using hyperterminal)

i know my code is working because i tried it on a sample design with a built in UART.

I hope you can help me and tell me what did i miss or something wrong on my process.

#ifdef AVALON_UART# else
// set line control reg to allow writing to baud divisor
IOWR_8DIRECT (UART_BASE, 3, 0x80);
// baud divisor = (clk) div (baud) div (16)
// 50M/115200/16 = 27.127 = 0x001B
// 30M/115200/16 = 16.276 = 0x0010
// 30M/9300/16 = 195
IOWR_8DIRECT (UART_BASE, 1, 0x00); // baud div hi
IOWR_8DIRECT (UART_BASE, 0, 16); // baud div lo
// set line control reg for 8 n
IOWR_8DIRECT (UART_BASE, 3, 0x03);# endif
{
 int x=0;
 char msg = 'A';
 FILE* fp;
 fp = fopen ("/dev/uart", "w");
 for(;;)
 {
 printf("waiting for input: \n");
 scanf("%d",&x);
  if (fp == NULL)
  {
  printf("cant access file");
  }
  if (x==1 & fp!=NULL)
  {
   printf("character sent\n");
   fprintf(fp, "msg");
   fclose (fp);
  }
  x=0;
 }
 return 0;
}

the software successfully compiled so i think there is no problem on that part (i've checked already the file path for uart and UART BASE name on system.h)

11 Replies