[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gpio pin not toggling


I am working with the newest version of the devboard_lx, and am trying to use 
the 16 data pins from the two parallel ports as outputs. After upgrading to 
2.4.19, I have now been able to toggle the gpio pins using the axis gpio 
driver. Everything seems to be working well, except that I cannot get
pin D0 on the par0 port to toggle. I have checked the inputs to the 
transceiver chip U2 with an oscilloscope, and it looks like the etrax 
chip itself is not toggling. The other 15 pins work fine.

Below is the main portion of a simple test program that toggles one
pin at a time. Is there anything I am doing wrong or missing? Or do
I have a defective board?


Sam Silverstein

(note: I will eventually drive pins on an Altera FPGA...thus the
unusual naming of the device :-)


#define ALTERA "/dev/gpiog"

int main (int argc, char *argv[])
  int i, k, bufsize, val[2], res, altera;
  unsigned long data, mask, oe, j;

  /* Check that the inputs are valid, and convert to integer */

  printf("received %d arguments.\n",argc);

  if (argc < 2) {
    printf("Not enough arguments. Exiting...\n");

  for (i=1;i<3;i++) sscanf(argv[i],"%d",&val[i]);

  printf("Executing %d cycles with delay %d between steps...\n",val[1],val[2]);

  altera = open (ALTERA, O_RDWR);

  if (altera < 0) {
    printf("Error in opening altera: %d \n",altera);
    perror ("open");

  mask = 0xffff << 8;
  oe = 0x1 << 5;
  ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_SETGET_OUTPUT), &mask);
  ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_SETBITS), oe);
  for (i=0; i<val[1]; i++){
    for (j=0; j<16; j++){
      data = mask - (0x1 << j+8);
      ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_CLRBITS), &mask);
      ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_SETBITS), data);
/* Now close the ports and exit the program */

  close (altera);