Forum Discussion

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

how to use UART with NIOS

so in an example in Altera's documentation on how to use the UART core, it shows this code as an example of how to print characters to the UART core as stdout. But it says right above the example that the HAL system library has been configured to use the UART as stdout. How do I do that?

# include <stdio.h>

int main ()

{

printf("Hello world.\n");

return

3 Replies

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

    Hi,

    In your nios2-ide software project, under the syslib project properties, have you set the system library options to use the uart for stdout and stdin?

    Please let me know if any of this doesn't make sense.

    Thanks,

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

    Well I'm not sure how I can edit the syslib properties but I did setup my uart as the stdout and stdin inside of the HAL.

    I actually got the terminal working now, I had a hardware issue. We have another device that was fighting with the fpga for the TX0 pin and so I was not sending the correct voltage to my MAX device.

    Thanks for your input.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Well I'm not sure how I can edit the syslib properties but I did setup my uart as the stdout and stdin inside of the HAL.

    I actually got the terminal working now, I had a hardware issue. We have another device that was fighting with the fpga for the TX0 pin and so I was not sending the correct voltage to my MAX device.

    Thanks for your input.

    --- Quote End ---

    In 'syslib properties' window, choose 'System Library'. There you can find the options for 'stdout', 'stdin' and 'stderr', for which you can choose the UART port. Good luck.