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

Re: gpio pin not toggling



Hi,
You are using a pointer where you shouldn't see below.

On Wednesday 04 December 2002 14.42, silver@xxxxxxx.se wrote:
> Hi,
>
> 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?
>
> Thanks!
>
> Sam Silverstein
>
> (note: I will eventually drive pins on an Altera FPGA...thus the
> unusual naming of the device :-)
>
> ==========================================================
..
>   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);

The above looks rather strange, do you want to toggle several bits at once?
(You first clear all bits then sets all except one)
Do you want 
data =0x1 << j+8;
instead?

>       ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_CLRBITS), &mask);

Don't use a pointer here! 
&mask is wrong - use either mask or data, I'm not sure what you're trying to 
do here.

>       ioctl(altera, _IO(ETRAXGPIO_IOCTYPE, IO_SETBITS), data);

>        usleep(val[2]);
>    }
>   }

Best regards
/Johan