Forum Discussion

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

Help with Basic Concept Please

Hello folks, Having lots of trouble understanding a simple concept. I would like to know how the data register works for this UART. From the Data sheet, this is what info i have:

device

RS-232 UART

configuration

Two 32-bit mapped registers

input/output

Either

address base

0x10001010

address map

address

r/w

description

base

R/W

Data Register

23:16 - Number of characters available to read (after this read - see Notes)

15 - read data valid

9 - parity error

7:0 - the data itself

base+4

R/W

Control Register

23:16 - Spaces available for writing

9 - Write interrupt is pending

8 - Read interrupt is pending

1 - Enable write interrupts

0 - Enable read interrupts

Now a simple question, Let's say i want to read the UART of the Board, i wrote a short code in C for (Altera Monitor Program) but i get a garbage as input. Using a Terminal on PC to send some characters, and would like to display them on the HEX Disp. Here is what i tried to do:

------------------------------------------------------------------------------

mask = ((*RS232_UART_DATA)&0xFF00FF); // Reading the UART and masking some bits

HEX=mask; // Storing data to be written to hex

------------------------------------------------------------------------------

The issue is before i even get to send a character from the PC side, i start seeing garbage on HEX. And when i do attempt to send a character, the HEX shows more garbage. At least i can be sure the data is being transmitted, but i have no knowledge on how to mask the DATA Register appropriately. ANY HELP WOULD BE APPRECIATED!!!!

Thanks.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Assuming your baud rate, etc settings match between the PC and FPGA board, you need to check the data valid bit. You only have input data when that bit is set. If it isn't set, come back later and check again. If the data valid bit is set the number of characters field will tell you how many bytes you can read before waiting for data valid again. The code you have doesn't do this.