Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

DE2-70 Nios II problem

Hi everyone,

First of all im newbie of FPGAs

Now im working with DE2-70 and my design works.

but i have new problem like,

../hello_world.c: In function `test1_led':

../hello_world.c:24: error: `IOWR_ALTERA_AVALON_PIO_DATA' undeclared (first use in this function)

../hello_world.c:24: error: (Each undeclared identifier is reported only once

../hello_world.c:24: error: for each function it appears in.)

../hello_world.c:24: warning: left-hand operand of comma expression has no effect

../hello_world.c:26: error: `PIO_RED_LED_BASE' undeclared (first use in this function)

../hello_world.c:26: error: syntax error before "led_mask"

../hello_world.c:28: warning: implicit declaration of function `usleep'

../hello_world.c:30:2: warning: no newline at end of file

../hello_world.c:30: error: syntax error at end of input

my code;

# include "system.h"

# include "altera_avalon_pio_regs.h"

# include "alt_types.h"

void test1_led(void){

alt_u32 led_mask=0;

while(1){

// green led control

// red led control

(IOWR_ALTERA_AVALON_PIO_DATA, led_mask); PIO_RED_LED_BASE

// toggle led

led_mask ^= 0xFFFFFFFF;

// sleep 0.2 second

usleep(200*1000);

} // while

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Does an output PIO called "pio_red_led" exist in your FPGA/SoPC Builder design? Judging from the messages, I gather that it doesn't.

    Cheers,

    slacker
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Actually, i dont know how to use variables in Nios II codes.

    in my SOPC design;

    led and switch are my pio names so can you help me how to read value or position of switches and how can i change values of leds.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    switch read:

    sw_rd=IORD(SWITCH_BASE,0X00);

    led write:

    ld_wr=IOWR(LED_BASE,0X00,1);

    sw_rd and ld_wr are two variables and if there are two bit LED mans 2 leds) then very first LED (LED[0]) will glow as there is "1" assigned to it.