Altera_Forum
Honored Contributor
12 years agoNIOS II Parallel I/O (PIO) Embedded Peripherals
Hi Everyone,
I am having trouble with the one of the commands/calls in the Nios II's "Binary Counter" template. I'm using Nios II 13.1. The command I have a question on is on the command "IOWR_ALTERA_AVALON_PIO_DATA(base, data)". I understand where to get the "base" information from, but I'm confused on what to send or put in the "data" part. I am trying to get 1 LED to blink every one second on my board (not a development board), but I don't know how to tell the Nios II processor to select the LED I want AND have it blink every second. Is all of that information supposed to be conveyed in the "data" portion? I've attached some simple code. The "LED_IO_FROM_NIOS" declaration is my PIO component in Qsys (and an 8 bit register in Quartus II) and I wanted to figure out how I can manipulate an LED that I declared as the 0th bit (LED_IO_FROM_NIOS[0]) to blink every second. On one example I've seen, the following was put in the "data" section (as shown and kept in my code below): count & 0x1. I don't know what the "& 0x1" corresponds to. I tried reading the PIO section of the "Embedded Peripherals" PDF, but it doesn't help much with what I'm having trouble with. Thanks for the help. The flashing LED code that I'm trying to use.# include "system.h"# include "altera_avalon_pio_regs.h"# include "Altera_UP_SD_Card_Avalon_Interface.h" int main() { int count = 0; int onesecond; while (1) { IOWR_ALTERA_AVALON_PIO_DATA(LED_IO_FROM_NIOS_BASE, count & 0x1); onesecond = 0; while (onesecond < 60000000) //60MHz clock { onesecond++; } count++; } return 0; }