Forum Discussion

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

IOWR, IORD macros

Hi,

In my NIOS processor i have add 4 INPUT PIO of 1 bit (IN_PIO0, IN_PIO1, IN_PIO2, IN_PIO3), 1 INPUT PIO of 32 bit (IN_PIO4) and 1 OUTPUT PIO of 32 bit (OUT_PIO5).

I'm writing the code in C++ in Nios 5.1 and i would like that initially the OUTPUT PIO (OUT_PIO5) is set to "00000000000000001111111111111111" and if the value of IN_PIO0 is 1, the OUT_PIO5 should value "11111111111111111111111111111111" otherwise the OUT_PIO5 should value "0000000000000000000000011111111".

I have wrote this code:

# include "altera_avalon_pio_regs.h"# include <stdio.h> # define in_pio_0_base_address 0x02110940# define in_pio_0_high_address 0x0211094F# define in_pio_1_base_address 0x02110950# define in_pio_1_high_address 0x0211095F# define in_pio_2_base_address 0x02110960# define in_pio_2_high_address 0x0211096F# define in_pio_3_base_address 0x02110970# define in_pio_3_high_address 0x0211097F# define in_pio_4_base_address 0x02110980# define in_pio_4_high_address 0x0211098F# define out_pio_5_base_address 0x0210990# define out_pio_5_high_address 0x021099F

void scriviFPGA(alt_u32 indirizzo, alt_u32 dato)

{

printf("I write the initial value\n");

IOWR_ALTERA_AVALON_PIO_DATA(out_pio_5_base_address, 00000000000000001111111111111111);

printf("I read the value of IN_PIO_0\n");

alt_u8 temp;

temp = IORD_ALTERA_AVALON_PIO_DATA(in_pio_0_base_address);

if

(temp == 1)

{

printf("the value of in_pio_0 is 1 so i write the new value of out_pio_5\n");

IOWR_ALTERA_AVALON_PIO_DATA(out_pio_5_base_address, 11111111111111111111111111111111);

}

else

{

printf("the value of in_pio_0 is 0 so i write the new value of out_pio_5 \n");

IOWR_ALTERA_AVALON_PIO_DATA(out_pio_5_base_address, 00000000000000000000000011111111);

}

}

Where are the errors?

Sorry for my english!

Please help me!

Thank you very much!

1 Reply

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

    --- Quote Start ---

    originally posted by gpsky@Apr 15 2006, 01:15 PM

    iowr_altera_avalon_pio_data(out_pio_5_base_address, 00000000000000001111111111111111);

    where are the errors?

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=14403)

    --- quote end ---

    --- Quote End ---

    What does it mean 00000000000000000000000011111111?????

    You should not write in binary format

    Try hex format

    For example, u should write,

    IOWR_ALTERA_AVALON_PIO_DATA(out_pio_5_base_address, 0xfff00);