[comp.sys.hp] HELP needed with GPIO interface

camiel@eutnv1.UUCP (Camiel Severijns) (06/05/89)

Hello netlanders,

 We are designing an interface between the 98622A GPIO interface in
our HP9000-330 computer (HP-UX 6.2) and a bus system that was developed
at our department. We have trouble with the full handshake mode of the
GPIO interface. If we execute the following code without linking the
dvio library and just after a system boot:

	#include <stdio.h>
	#include <fcntl.h>

	main()
	{
		int i;
		char character;

		gpio_dev = open("/dev/gpio", O_RDWR);
		for (i = 0; i < 1000000; i++)
		{
			write(gpio_dev, character, sizeof(char));
			printf("Character 1 written\n");
			write(gpio_dev, character, sizeof(char));
			printf("Character 2 written\n");
		}
		close(gpio_dev);
	}

and use a bus monitor to simulate handshaking manually, the first
write() doesn't wait for the PFLG to become low but the second does.
The bus monitor we use has LED's showing all output lines from the
GPIO interface and switches with Schmitt-triggers to control the
input lines. It was made according to the spec's in the GPIO manual
supplied with the GPIO interface.

We have tried a test supplied by the respons center in Amstelveen,
the Netherlands. It tests the GPIO interface in PULSE mode by simply
connecting the PCTL to the PFLG and setting the correct sense of the
logic. This seems to work correctly on the oscilloscope and according
to the respons center the GPIO interface should therefore be okay.

Can someone help us with this problem ? Has any of you netlanders ever
developed an interface for GPIO ? If so, could you tell us how you
designed your interface ?

Thanks in advance,

-- 
| Camiel Severijns
| Dept. of Physics, Eindhoven University of Technology
| Den Dolech 2, POBox 513, 5600 MB, Eindhoven, The Netherlands
| UUCP: eutnv1.uucp!camiel OR: eutrc3.uucp!tnvscs

rdg@hpfcmgw.HP.COM (Rob Gardner) (06/07/89)

>  We are designing an interface between the 98622A GPIO interface in
> our HP9000-330 computer (HP-UX 6.2) and a bus system that was developed

> 		char character;
> 
> 		gpio_dev = open("/dev/gpio", O_RDWR);

Check the return value from the open. This could easily fail!!

Also, if you are writing one char at a time, add in:

		io_width_ctl(gpio_dev, 8);	/* need to link w/ -ldvio */
		io_reset(gpio_dev);		/* usually a good idea */

> 		for (i = 0; i < 1000000; i++)
> 		{
> 			write(gpio_dev, character, sizeof(char));
                                        ^^^^^^^^^

You need &character here to get the correct data out. You're lucky this
doesn't simply core dump. Check the return value here also.

> and use a bus monitor to simulate handshaking manually, the first
> write() doesn't wait for the PFLG to become low but the second does.

Check the senses of the handshake switches on the 98622 card, as they
can affect the logic.

 
    Rob Gardner                     hplabs!hpfcmr!rdg
    Hewlett Packard                 or rdg%hpfcmr@hplabs.hp.com
    Fort Collins, Colorado          303-229-2048
		80525-9599

		     "Ask me about Home Brewing"