Forum Discussion

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

need help in c code for communication between Nios ii processor and custom component.

hi ,

i am done with my qsys design . now i want to move to the next steps. i wan to send data from my nios II processor to the custom Component ( encoder) , i created. can any one suggest me any example codes. i need to send a 32 bit data to the custom component from nios II processor. please do suggest me ...

5 Replies

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

    add 32 bit PIO from u r qsys (i haven't much idia about qsys, i am using SOPC builder) , and write u r data on this bus using u r c- code,

    don't forget to add this 32 bus to u r nios-ii symbol.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i am asking can anyone give me a C code for communication from nios II processor to some custom block i created. i am done with qsys. it is compiled. no issues. please do help with the c code

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

    ho about

    ///////////////////////// c code (^v^ )/////////////////////////////////////////

    # include <io.h>

    # include <system.h>

    .....

    short pio_button;

    pio_button = IORD_16DIRECT(PIO_BUTTON_BASE,0);

    IOWR_16DIRECT(PIO_LED_BASE,0,pio_button);

    ///////////////////////////////////////////////////////////////////////////////////

    IORD_16DIRECT is reading register from address of PIO_BUTTON_BASE

    IOWR_16DIRECT is writing data to PIO_LED_BASE

    those base addresses are written in <system.h>

    serch IOWR_*DIRECT functions