Altera_Forum
Honored Contributor
12 years agoBidirection port (PIO) in uClinux
Hi all,
does somebody design and program, in which is using pio core in bidirection mode ? I need to communicate between two FPGAs with one control bus (in output pio mode) and bidirection bus for address and data, but when i use program like this ------------ void write_sigp(unsigned long adresa,unsigned long hodnota) { printf("Zapisuji hodnotu na adresu 0x%x=0x%x.\n",adresa,hodnota); // set output mode on io bus outl(0xFFFFFFFF,IO_PIO_SMER+0x80000000); //write address on io bus outl(adresa,IO_PIO+0x80000000); usleep(1); // strobe address outb(NONE-ASTB,OUTPUT_PIO+0x80000000); usleep(1); outb(NONE,OUTPUT_PIO+0x80000000); usleep(1); // write data on io bus outl(hodnota,IO_PIO+0x80000000); usleep(1); // set /WR signal outb(NONE-WR,OUTPUT_PIO+0x80000000); usleep(1); outb(NONE,OUTPUT_PIO+0x80000000); // set input direction of io bus outl(0x00000000,IO_PIO_SMER+0x80000000); } // reading from second fpga unsigned long read_sigp(unsigned long adresa) { unsigned long out_data=0xffffffff; // set output direction pio outl(0xFFFFFFFF,IO_PIO_SMER+0x80000000); // write address on io bus outl(adresa,IO_PIO+0x80000000); usleep(1); // strobe addres outb(NONE-ASTB,OUTPUT_PIO+0x80000000); usleep(1); outb(NONE,OUTPUT_PIO+0x80000000); usleep(1); // set input direction in io bus outl(0x00000000,IO_PIO_SMER+0x80000000); // set /RD signal outb(NONE-RD,OUTPUT_PIO+0x80000000); usleep(1); // read value from io bus out_data = inl(IO_PIO+0x80000000); // reset /RD signal outb(NONE,OUTPUT_PIO+0x80000000); usleep(1); printf("Nacitam hodnotu z adresy 0x%x=0x%x.\n",adresa,out_data); return(out_data); } ------------ IO_PIO_SMER = IO_PIO base address + 1 ------------ nothing is setting in bidirection bus on their pins. In output pio bus is setting and reseting control signal right. Or is neccessary to use some linux driver for use io bus ? Where, or how to set ? (when i use only nios2 processor and c language, it works ok) Thank you for your answer. Jan Naceradsky, Czech Republic