Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

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

Altera_Forum
Honored Contributor II
1,812 Views

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.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
867 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Thanks for reply.  

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

How to get the example?
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

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.
0 Kudos
Reply