Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

accessing the uart status register

Altera_Forum
Honored Contributor II
993 Views

how do i access the status register of the uart  

using the HAL librery
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
317 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
317 Views

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?
0 Kudos
Altera_Forum
Honored Contributor II
317 Views

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 )

0 Kudos
Altera_Forum
Honored Contributor II
317 Views

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)
0 Kudos
Reply