- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I made a project with a Nios II processor, and I am currently trying to get data from UART. I tried using the getc function and it works fine, I received all the data. I also tried using register (checking the bit RRDY of the status register) but I don't get all the data (in average, I received a third of the data I send, but it is not constant). For the test, I use a simple rs232 terminal (Termite), and send byte by byte manually, so it is not a problem of speed. In my code, I just get data from uart and display the value on leds, I think my code is correct (I put the two methods used below), but I don't see why it doesnot work correctly, if anyone has an idea. Thanks in advance. Jérôme
// Reading uart using HAL (works all the time)
FILE* file;
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, ~0x00);
file = fopen (UART_NAME, "r+");
do
{
data = getc(file);
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, ~data);
}while(1);
// Reading uart using register (works sometimes)
do
{
status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);
if( (status & ALTERA_AVALON_UART_STATUS_RRDY_MSK) != 0)
{
data = IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE);
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, ~data);
}
}while(1);
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi, same mistake
try with ALTERA_AVALON_UART_STATUS_tRDY_MSK. I don't know why it works for me. EDIT : Sorry, wrong way- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here I don't send data, so the bit TRDY is always at 1.
Else, this phenomenon is strange because, if I enable interrupt on reception, when I have an interrupt I get all bytes correctly using the same method.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use this in "interrupt on reception", it works well.
In a superloop, reading if RRDY is active is not recommended I think. It is a mistake for me too.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page