Forum Discussion

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

how to read with altera_jtag_uart_read

Hi,

I have some code that works only the first time.

See here below

int alt_main(void)
{
    char p="InitText";
    while(1)
    {
      alt_printf("\nread trough jtag_uart_read");
      altera_avalon_jtag_uart_read(JTAG_UART_0_BASE, &p,3,O_RDWR |O_NONBLOCK) ;
      alt_printf("\np=%s", p);
 
    }
 return 0;
}

Current code above reads only the first time a character into the string p[20].

Question 1: How do I change this so that it reads every time the new character?

Question 2: How do I read with altera_avalon_jtag_uart_read the registers of the JTAG UART Core?

This JTAG UART Core Register Map is defined as:

+-------------------------------------------------------------------------------------+
|Offset | Register | | Bit Description |
| | Name | R/W |31 ... 16| 15 | 14 ... 11| 10 09 08 |07 ...... 02| 01 |00 |
+-------------------------------------------------------------------------------------+
| 0 | data | RW | RAVAIL |RVALID |Reserved | Reserved | DATA |
+-------------------------------------------------------------------------------------+
| 1 | control | RW | WSPACE |Reserved | AC WI RI | Reserved |WE|RE|
+-------------------------------------------------------------------------------------+

I can access it with IORD

For example: i = IORD(JTAG_UART_0_BASE, ALTERA_AVALON_JTAG_UART_DATA_REG);

But it's recommended to use altera_avalon_jtag_uart_read.

So is the following possible?

 
int main (void)
{
  alt_u32 data;
  alt_u32 ravail;
  alt_u32 wspace;
 
 // read the data into var data (do some '& and | processing afterwards to filter the 8bits out
  altera_avalon_jtag_uart_read (JTAG_UART_0_BASE, &data, 1, O_RDWR |O_NONBLOCK) ;
 
  // read the read available into var ravail (do some '& and | processing afterwards to get the right bit)
  altera_avalon_jtag_uart_read (JTAG_UART_0_BASE, &ravail, 1, O_RDWR |O_NONBLOCK) ;
 
 // read the write space into var wspace (do some '& and | processing after wards to filter the 16bits out)
  altera_avalon_jtag_uart_read (JTAG_UART_0_BASE+1, &wspace, 1, O_RDWR |O_NONBLOCK) ;
  return 0;
}

Rgds,

Kimberley
No RepliesBe the first to reply