Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
777 Views

Pio 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!
Tags (1)
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
29 Views

Hi, 

 

Maybe how data has interpreted is a problem. 

LSB bits are considered during reading & writing. 

  1. What is the PIO width set?  

  2. Can you share your code? 

 

Or  

Try with below code. 

Example1: For single bit controle consider below code and try 

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, count & 0x01); while(delay < 2000000) { delay++; } count++;  

 

Example2: 2-PIO of 3bits of width, for switches and leads. 

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); ............ }  

 

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)
Altera_Forum
Honored Contributor I
29 Views

 

--- Quote Start ---  

Hi, 

 

Maybe how data has interpreted is a problem. 

LSB bits are considered during reading & writing. 

  1. What is the PIO width set? 

  2. Can you share your code? 

 

Or  

Try with below code. 

Example1: For single bit controle consider below code and try 

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, count & 0x01); while(delay < 2000000) { delay++; } count++;  

 

Example2: 2-PIO of 3bits of width, for switches and leads. 

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); ............ }  

 

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!
Reply