Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
761 Views

basic question

Hi, 

Well it looks very stupid question for many people, but I am new to nios. I have used count binary templet to test my board and it is working fine.I can see the leds blinking and I can see the programm is running in console window. 

In one document I have seen I can read values from console window.What function should I use to read the data from console window (any key press from keyboard ).I am very new to microcontroller programing,so can some one sugest me to read some documents. 

Thanks in advance, 

Sarat
0 Kudos
5 Replies
Highlighted
Valued Contributor III
2 Views

Yeah, all documents are good to read, depending on your interest, you can start with "intros" "tutorials" then end up with Handbooks for NIOSII or SW dev 

niosii handbook n2cpu_nii5v1 (http://www.altera.com/literature/hb/nios2/n2cpu_nii5v1.pdf)  

niosii software handbook n2sw_nii5v2 (http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf)  

tt_qsys_intro (http://www.altera.com/literature/tt/tt_qsys_intro.pdf)  

but I guess you'll first begin with the manuals of your board. 

To answer your question, you can use a JTAG uart or real uart that you open on console window with "nios2-terminal" (see tutorials for more details). That makes you receive with NIOSII what you type on the console.
0 Kudos
Highlighted
Valued Contributor III
2 Views

Hi, 

Thank you for your reply, 

I am just using scanf or getchar for reading from console.I am getting one error says "undefined refference to scanf".I strongly belive it is not the way to deal with microcontrollers.I have seen my ALT_STDIN_DEV is JTAG_UART in system.h file.so what I think is I have to use some built in function for altera devices (for example for displaying LEDs there is a function IOWR_ALTERA_AVALON_PIO_DATA( PIO_LED_BASE, dis ); ) . Where can I get information about these functions ? Can you please post me if you have some example programs (any example works on nios ). 

sarat
0 Kudos
Highlighted
Valued Contributor III
2 Views

Hi Wass, 

thank you for your help.I can read charecters from consloe now using getchar().but still if you have any example programs can you please post. 

Sarat
0 Kudos
Highlighted
Valued Contributor III
2 Views

Hi, 

once you got the getchar() working, the rest is about c programming. 

About PIO's, I assume you already have a PIO component on your system (from the SOPC Library\peripherals\Microcontroller Peripherals), then you would just be writing on its base address and the PIOs would take the binary value of what you write. 

A good doc to start with if you still didn't look at: 

http://www.altera.com/literature/tt/tt_my_first_nios_sw.pdf 

(http://www.altera.com/literature/tt/tt_my_first_nios_sw.pdf)
0 Kudos
Highlighted
Valued Contributor III
2 Views

Hi Wass, 

Now I understood how to send data to pios.Thank you very much for your help. 

Sarat
0 Kudos