Forum Discussion

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

accessing the uart status register

how do i access the status register of the uart

using the HAL librery

4 Replies

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

    You shouldn't need to. The HAL provides a device driver which does all the hardware access for you - it will get confused if other software starts accessing the hardware directly.

    What information do you need that you'll get from reading the port?

    ps. Of course a read from the status register should be safe - you can hack this (for debug purposes) using the IORD_ macro from the uart include file and the base address from system.h
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thanks wombat

    I know that I can read and write to the uart using fprintf and fscanf.

    but to synchronize the transmit and the data received shouldn't I monitor the status register

    like it was done when the excalibar was used ?

    what about the control register shouldn't I access it directly?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Would interupts be better for you? You can fire data into the tx register (using the HAL command for it), and read the rx register (again using the HAL command for it when it interupts the CPU). I tried doing what you were suggesting with Nios I before and it was a big pain so I just used the routines provided with the kit (why re-invent the wheel if the wheel is already round and working http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif )

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

    Hi BadOmen,

    if this wheel is really round,

    please can you answer me the following question.

    I have configured the UART in SOPC Builder with RTS/CTS,

    but I don&#39;t want to use it in software.

    If I have no cable attached (CTS high), program hangs.

    How can I clear the device flag "ALT_AVALON_UART_FC" by software ???

    static void alt_avalon_uart_txirq (alt_avalon_uart_dev* dev,

    alt_u32 status)

    {

    /* Transfer data if there is some ready to be transfered */

    if (dev->tx_start != dev->tx_end)

    {

    /*

    * If the device is using flow control (i.e. RTS/CTS), then the

    * transmitter is required to throttle if CTS is high.

    */

    // !!!TF

    // if (!(dev->flags & ALT_AVALON_UART_FC) ||

    // (status & ALTERA_AVALON_UART_STATUS_CTS_MSK))

    if(1)