Forum Discussion

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

Rewrite "while((rcvdata = nr_uart_rxchar((np_uart *) 0x00000800)) == -1);" for NiosII

I used to create the Nios project.

But, I am a very newcomer for Nios II. so, I want to ask you about my trouble.

In Nios project, I used UART to receive the data into Nios. And I used the below code (C langauge) to do that. It can work without the problem. (rcvdata is int)

----------------------------------------------------------------------

"while((rcvdata = nr_uart_rxchar((np_uart *) 0x00000800)) == -1);"

----------------------------------------------------------------------

But, in case of Nios II, according to "Upgrading Nios Processor Systems to the Nios II Processor", it seems that the source code should be rewrited.

According to page 27 of that document, the "getchar()" should be used instead of "nr_rxchar()". so, I changed the above code to

----------------------------------------------------------------------

"rcvdata = getchar();" .

----------------------------------------------------------------------

But, it seems that I did something wrong. The project cannot be built. :confused::confused::confused:

Could you tell me how to correct it, please.

Thank you very much in advance, and sorry for my English.

3 Replies

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

    Hi,

    getchar() gets a character from stdin that you have to fix somewhere.

    May it help you even if it is a little help.

    Do you work with Nios II IDE and SOPC Builder ? In which case, you have software examples.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for reply.

    Yes, I work with Nios II IDE and SOPC Builder.

    How to get the example?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    installation of nios ii ide includes this examples. Maybe you have to reinstall NIOS II IDE.

    In Nios II IDE, You can create project by menu File>New>Nios II application> here you find example templates. But this examples works only with altera dev kits.

    If you are newbie in NIOS II IDE, I suggest you to read "getting started" somewhere in Altera website.