- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there...i'm currently having problem of understanding the pin input pio....
my nios is connected to the 16 bits pio pin in the development board...how to write a c code to retrieve the inputs from this pio.. since this inputs are in binary, do i need to convert to decimal or the system itself will convert for me in C language. thnaks and regards wayneLink Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by niceguylow@Dec 7 2005, 02:56 PM hi there...i'm currently having problem of understanding the pin input pio....
my nios is connected to the 16 bits pio pin in the development board...how to write a c code to retrieve the inputs from this pio..
since this inputs are in binary, do i need to convert to decimal or the system itself will convert for me in c language.
thnaks and regards
wayne
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11393)
--- quote end ---
--- Quote End --- You can try using the PIO functions made available by Altera... like the one used in the count_binary example of the HAL... The numbers you'll read from the PIO have to be interpreted as a set of bits inside a 32-bit integer... For example, if you have a 2 bit PIO, you'll end up having the 2 bits valies inside the 2 less significant bits of the integer you read from the peripheral. bye Paolo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by paolo.gai+dec 7 2005, 08:38 am--><div class='quotetop'>quote (paolo.gai @ dec 7 2005, 08:38 am)</div>
--- quote start ---
<!--quotebegin-niceguylow@Dec 7 2005, 02:56 PM hi there...i'm currently having problem of understanding the pin input pio....
my nios is connected to the 16 bits pio pin in the development board...how to write a c code to retrieve the inputs from this pio..
since this inputs are in binary, do i need to convert to decimal or the system itself will convert for me in c language.
thnaks and regards
wayne
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11393)
--- quote end ---
--- Quote End --- You can try using the PIO functions made available by Altera... like the one used in the count_binary example of the HAL... The numbers you'll read from the PIO have to be interpreted as a set of bits inside a 32-bit integer... For example, if you have a 2 bit PIO, you'll end up having the 2 bits valies inside the 2 less significant bits of the integer you read from the peripheral. bye Paolo <div align='right'><{post_snapback}> (index.php?act=findpost&pid=11396)</div> [/b] --- Quote End --- this is my sample of the c ....will it work ? let say my pio is a 16 bit input...would it put receive the 16 bits input. since np_pio is defined as int...the 16 bits are automatically converted into integer? np_pio *pio = na_pio; if i want to access obtain the data... pio->np_piodata;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you using IORD_ALTERA_AVALON_PIO_DATA(base) ?
Paolo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello niceguylow,
the PIO Core is described in the Quartus II Development Software Handbook Volume 5: Embedded Peripherals (http://www.altera.com/literature/quartus2/lit-qts-peripherals.jsp). For accesing the PIO registers there are some macros which are included in “altera_avalon_pio_regs.h”:#define IOADDR_ALTERA_AVALON_PIO_DATA(base) __IO_CALC_ADDRESS_NATIVE(base, 0)# define IORD_ALTERA_AVALON_PIO_DATA(base) IORD(base, 0) # define IOWR_ALTERA_AVALON_PIO_DATA(base, data) IOWR(base, 0, data)
# define IOADDR_ALTERA_AVALON_PIO_DIRECTION(base) __IO_CALC_ADDRESS_NATIVE(base, 1)# define IORD_ALTERA_AVALON_PIO_DIRECTION(base) IORD(base, 1) # define IOWR_ALTERA_AVALON_PIO_DIRECTION(base, data) IOWR(base, 1, data)
# define IOADDR_ALTERA_AVALON_PIO_IRQ_MASK(base) __IO_CALC_ADDRESS_NATIVE(base, 2)# define IORD_ALTERA_AVALON_PIO_IRQ_MASK(base) IORD(base, 2) # define IOWR_ALTERA_AVALON_PIO_IRQ_MASK(base, data) IOWR(base, 2, data)
# define IOADDR_ALTERA_AVALON_PIO_EDGE_CAP(base) __IO_CALC_ADDRESS_NATIVE(base, 3)# define IORD_ALTERA_AVALON_PIO_EDGE_CAP(base) IORD(base, 3) # define IOWR_ALTERA_AVALON_PIO_EDGE_CAP(base, data) IOWR(base, 3, data)
Regards, niosIIuser
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.......
alt_16 my_data; ..... my_data = IORD(YOUR_PIO_BASE_ADDRESS,0); ......
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page