Forum Discussion
Altera_Forum
Honored Contributor
8 years agoPio write data error
Hi all,
I am using IOWR_ALTERA_AVALON_PIOS macros to write data onto pios. But when I am writing the data onto 1 pins, all the other pins are assigned the same value at the same time. Does anyone know why this happens? Thank you very much!2 Replies
- Altera_Forum
Honored Contributor
Hi,
Maybe how data has interpreted is a problem. LSB bits are considered during reading & writing.- What is the PIO width set?
- Can you share your code?
Example2: 2-PIO of 3bits of width, for switches and leads.IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, count & 0x01); while(delay < 2000000) { delay++; } count++;
Let me know if this has helped resolve the issue you are facing or if you need any further assistance. Best Regards, Anand Raj Shankar (This message was posted on behalf of Intel Corporation)int in; while (1) { in = IORD_ALTERA_AVALON_PIO_DATA(SW_PIO_BASE) & 0x07;//we are consedering/requried least 3bits from switch if(in==0)//if all swith are zero IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0); else if(in==1) IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 1); ............ } - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, Maybe how data has interpreted is a problem. LSB bits are considered during reading & writing.- What is the PIO width set?
- Can you share your code?
Example2: 2-PIO of 3bits of width, for switches and leads.IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, count & 0x01); while(delay < 2000000) { delay++; } count++;
Let me know if this has helped resolve the issue you are facing or if you need any further assistance. Best Regards, Anand Raj Shankar (This message was posted on behalf of Intel Corporation) --- Quote End --- Hi, The DB Width I am setting is 8 bits. It is for driving LCD. I have fixed previous problem. But now, I have a new problem. When I am trying to write DB. I got nothing on this 8-bits width signal out onto oscilloscope. The code is attached. # include "stdio.h"# include "stdint.h"# include "unistd.h"# include "system.h"# include "linker.h"# include "lcd_driver.h" //#include "Character.h"# include "altera_avalon_pio_regs.h" //#include "lcd_driver.h" int main() { while(1){ IOWR_ALTERA_AVALON_PIO_DATA(LCD_DB_BASE, 0x01); usleep(50000); IOWR_ALTERA_AVALON_PIO_DATA(LCD_DB_BASE, 0x00); usleep(50000); } return 0; } In this code, DB[0] should be toggled, right? which is not. My setting for this pio peripheral is 8-bit width as output. Could you help me with that? Thank you very much!int in; while (1) { in = IORD_ALTERA_AVALON_PIO_DATA(SW_PIO_BASE) & 0x07;//we are consedering/requried least 3bits from switch if(in==0)//if all swith are zero IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0); else if(in==1) IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 1); ............ }