Posts: 18
Joined: Thu Sep 20, 2018 4:19 am

GPIO programming

Sat Sep 22, 2018 6:15 pm

GPIO programming - I have a group of GPIO ports (say port 10,11,12,13,14,15,16,17) as an 8bit data port - I want to set an 8bit data to that 8bit data port? is there a function to set that value or do i have to convert to binary and set each bit to each gpio individually? - how about 16 data port with 16 bit value?

User avatar
Posts: 12855
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: GPIO programming

Sat Sep 22, 2018 6:24 pm

I think pigpio has a method for writing certain GPIOs in bulk. You could write your own driver. The gpios outputs are controlled by 32-bit words. There are two for each set of 32 gpios. Writing 1 to any bit on one of them will set the corresponding gpio high, writing 1 to bits in the other word set the corresponding gpio(s) low. writing 0 to any bit will not change the state of the gpio. This means you have to do two writes to set multiple gpios, one write to set the 1 bits and one write to set the 0 bits. It's slightly more complicated that just writing a value to a port, but means you can easily control individual gpios without affecting others in the same bank.

Return to “General programming discussion”