Altera_Forum
Honored Contributor
20 years agowhy is it base address?
I make leds light by using PIO of sopc!
but i must change some code in niosII IDE!# include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h" /* * This is a freestanding application, so we want to use alt_main * as the entry point. However, if the debugger is run on this * application, it will try to set a breakpoint at main, which * the application does not contain. The below line creates an * alias so the debugger is able to set a breakpoint at main, * yet the application retains alt_main as it's entry point. */ int main (void) __attribute__ ((weak, alias ("alt_main"))); /* * Use alt_main as entry point for this free-standing application */ int alt_main (void) { alt_u8 led = 0x2; alt_u8 dir = 0; volatile int i; /* * Infinitly shift a variable with one bit set back and forth, and write * it to the LED PIO. Software loop provides delay element. */ while (1) { if (led & 0x81) { dir = (dir ^ 0x1); } if (dir) { led = led >> 1; } else { led = led << 1; } IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, led); // Write led data to the address of pio_o_base /* * The delay element in this design has been written as a while loop * to avoid confusing the software debugger. A tight, one line software * delay loop such as: * for(i=0; i<200000; i++); * can cause problems when it is stepped through using a software debugger. * The while loop below produces the same behavior as the for loop shown * above, but without causing potential debugger problems. */ i = 0; while (i<20000) i++; } return 0; } I donot know why I must change LED_PIO_BASE to PIO_0_BASE?