xyphro / UsbGpib

Versatile, cheap and portable USB to GPIB converter (USBTMC class based)
MIT License
288 stars 51 forks source link

AVR Port usage #16

Closed sufzoli closed 1 year ago

sufzoli commented 2 years ago

Hi,

I'm trying to adapt your code for my own board design (https://gitlab.com/measurementcontrol/gpibinterfacehardware/-/tree/V2.0). I see that you are writing data to the DDRx registers and not to the PORTx registers (gpib.c). According to the internet sources the DDRx is the data direction register (In/Out) and the PORTx is the data out register. What I miss here?

Thank you, Zoltan

xyphro commented 1 year ago

Hi Zoltan,

this is intended usage.

GPIB uses so called open drain logic. This is very similar to I2C.

The instrument has internal pullup resistors (or current sources) on the GPIB bus pins. The GPIB device but also the instrument pulls the lines LOW to create a 0 on the bus. A HIGH is created by putting the GPIO pin direction to input, which creates a tristate and allows the mentioned pullup resistor to create a high level.

By defining a bus like this you can be sure to never have conflicts, i.e. one side driving a HIGH, while another side puts the pin LOW again.

Success with your creation!

Best regards,

Kai

xyphro commented 1 year ago

closing.