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++

Read JTAG UART nios II

Honored Contributor II




I'm starting to learn some verilog coding and nios II. I'm using the book "Embedded SoPC Design with Nios II Processor and Verilog Examples" and in one example the JTAG UART is accessed directly without the HAL. The write function was provided in the example and it works fine. But I set out to make a read function. However unsuccessful. I know that the transmission of data from the PC works if I use the routines provided by the HAL but my implementation does not work.  


I do this to read from the JTAG UART: 


// Read from the JTAG UART address 

alt_32 wrd = IORD(JTAG_UART_BASE,0); 

// Check if the data is valid 

if (wrd & 0x00008000) 

// If so, get the 8 bits that correspond to the character 

wrd = (wrd & 0x000000ff); 


wrd = -1; 


When I debug the code the value of wrd is always the same no matter what I send from my PC. I suspect that maybe the HAL gets an interrupt whenever a character i received and clear this register. Is that what happens? If so, is there any way to turn off this functionality?  


Kind regards, 

0 Kudos
1 Reply
Honored Contributor II

Hi, did you write your code in an interrupt or in the main program ? 



You employ a function when you initialize a local variable : alt_32 wrd = iord(jtag_uart_base,0);

You should first initialize the variable : alt_32 wrd = 0; 

then read a char from UART and store it to the wrd variable : wrd= IORD...; 



There are MACROs to read a character or send a character from/to UART :  


char crd; 

0 Kudos