Forum Discussion

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

Uart data ready

Hi all,

I am periodically sending data from LabView to my cycloneIII development kit (bemicro) and I want to check if there is data available to be read in NIOS II. Unfortunately, I have not been able to use the data ready bits, can someone enlighten me on how to do this?!

Do I need to use

ALT_UART_READ_RDY 0x1

or

ALTERA_AVALON_UART_CONTROL_RRDY_MSK (0x80) ?

If yes, how am I supposed to do so? Any help would be appreciated!

marek

16 Replies

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

    Be sure that uart_base matches to your SOPC UART_BASE :

    maybe you have changed your sopc (in Quartus SOPC Builder) and you have forgotten to rebuild your "system library" (I don't know the exact name in NIOS > 9.1, perhaps "BSP" :confused:) in NIOS IDE (or SBT or ...)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi again,

    It seems that the foloowing statement does not return the proper status bits.

    status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);

    Are there any specific functions that can mess with the status bits? Do I need to initialize something in particular for this to work? Any special includes?

    I would appreciate some help!!!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for the replies. Unfortunately I still didn't get the code to work, the if statement returns remains false... Does anyone have any suggestions?

    BTW, it should read: if (status & altera_avalon_uart_status_rrdy_msk) instead ofif (status & altera_avalon_uart_control_rrdy_msk).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    No, if (status & altera_avalon_uart_control_rrdy_msk) is a good code (fails only if mask=0x0 which doesn't usually happen).

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

    --- Quote Start ---

    status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);

    if (status & ALTERA_AVALON_UART_CONTROL_RRDY_MSK)

    {

    }

    --- Quote End ---

    In this IF statement,you have put ' & ' operator which is not logical and.It is bitwise and,so any value except 0x00,will cause to go into IF body

    I think you should compare your IF result to some specific hex value that you want to get

    Ex: if ( status & ALTERA_AVALON_UART_CONTROL_RRDY_MSK == 0x..)

    {

    temp_read= read_data;

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

    To test if there is data ready to be read I use the following code.

    status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);

    if (status & ALTERA_AVALON_UART_CONTROL_RRDY_MSK)

    {

    }

    However, it seems that the if statement is false even when there is data available. Can anyone help?