Forum Discussion

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

Program runs in loop

I have written a program that writes to the user through nios 2 console (jtag uart) and takes user input as well. However, the program does not pause to accept user input. Instead it continues to run the main in a loop. Is there a way to get the console to pause and wait for user input as it does in local console applications.

If code is needed I will be happy to post. Thank you for any help

5 Replies

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

    Do these functions work with only small c library? I have limited memory resources for the system. I chose not to support c++ in the BSP options

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

    Ahhh, if you're using the small C library, you're going to have to get trickier.

    If I remember right, you may may be able to use the regular "read()" function which I think will block.

    You may also want to access the UART driver directly ...

    data = IORD_ALTERA_AVALON_JTAG_UART_DATA(JTAG_UART_0_BASE);
    if(data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK){
         // If you're here you've got data to read.
         data = data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK;
    }else{
         // No data try again
    }

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

    Yes i tried using the read() function which doesnt seem to pause. I will try accessing the UART directly but if you could explain a little why those masks are used in the code snippet I think I could better understand where exactly to access the UART in my code.

    Thank you for your help.

    Chase