Page 1 of 1
Raspberry Pi Input Pullup
Posted: Sun May 03, 2020 12:24 pm
by Maes2ro
I have just started using flowcode 8 with a Raspberry Pi 3B+.
I am successfully writing to a graphics display, and can do basic stuff like switching outputs. However I am unable to work out how to enable the input Pullup resistors. It would be great if someone could help me out with this.
Re: Raspberry Pi Input Pullup
Posted: Mon May 04, 2020 11:02 am
by Benj
Hello,
You could try using this in a C code icon.
MX_GPIO_PULL = 0;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0x7FFFFFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
Instead of writing 0 to MX_GPIO_PULL use a bit mask of the GPIO pins you would like to enable.
e.g. 0x3 would enable pins 0 and 1.
Let us know how you get on.
Re: Raspberry Pi Input Pullup
Posted: Mon May 04, 2020 4:27 pm
by Maes2ro
Hi Ben
That makes sense, thank you. I will try that a little later.
Regarding the bit masking, I would like to use the following pins as inputs
7 G0/7
8 G1/0
12 G1/4
14 G1/6
15 G1/7
16 G2/0
18 G2/2
20 G2/4
21 G2/5
23 G2/7
24 G3/0
25 G3/1
Should I assemble a bit mask for the entire 28 bits of the GPIO (I think its 0 to 27, with 0 & 1 being reserved), which looks like this
0000000110001011101011011100
and converts to 0x18BADC
or maybe (depending were the LSB is)
0011101101011101000110000000
0x3B5D180
Or is it banked into four 8 bit ports, as per the flowcode structure?
Re: Raspberry Pi Input Pullup
Posted: Tue May 05, 2020 9:34 am
by Maes2ro
I've been digging away at this, still without success, but I am making some progress gathering insight into the process.
looking at the code fragment you kindly sent me:
MX_GPIO_PULL = 0;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0x7FFFFFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
This suggests that we set up the pullups with MX_GPIO_PULL then clock them in with MX_GPIO_PULLCLK0, the value assigned to this function being another bit mask ( I guess)
What is not clear though is why this clock is 27 bits, when I think the GPIO is 28 bits wide - 0&1 being reserved for the Eeprom I2C bus
To simplify things I have chosen to set leave 0 to 11 as whatever the default is, and set pullups on everything above that, so assuming that the LSB is on the right, this gives us a bit pattern of
111111111111111100000000000 = 0x7FFF800
and I thought I might as well clock the whole lot in:
MX_GPIO_PULL = 0x7FFF800;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0x7FFFFFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
Sadly, this doesn't work though
Just for fun, I flipped the bit pattern over and tried
000000000000111111111111111 = 0x7FFF
MX_GPIO_PULL = 0x7FFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0x7FFFFFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
But this doesn't work either.
I must be still missing something here.
Re: Raspberry Pi Input Pullup
Posted: Tue May 05, 2020 7:51 pm
by LeighM
MX_GPIO_PULL = 2; // enable pull-ups command
mx_delay_u(100);
MX_GPIO_PULLCLK0 = BIT MASK OF GPIOs TO SET;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
Re: Raspberry Pi Input Pullup
Posted: Sat Jul 11, 2020 5:13 pm
by Maes2ro
Many apologies for the belated reply, but this now works fine.
Thank you very much for your help