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.
Raspberry Pi Input Pullup
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Raspberry Pi Input Pullup
Hello,
You could try using this in a C code icon.
e.g. 0x3 would enable pins 0 and 1.
Let us know how you get on.
You could try using this in a C code icon.
Instead of writing 0 to MX_GPIO_PULL use a bit mask of the GPIO pins you would like to enable.MX_GPIO_PULL = 0;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0x7FFFFFF;
mx_delay_u(100);
MX_GPIO_PULLCLK0 = 0;
e.g. 0x3 would enable pins 0 and 1.
Let us know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Raspberry Pi Input Pullup
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?
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
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.
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.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Raspberry Pi Input Pullup
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;
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
Many apologies for the belated reply, but this now works fine.
Thank you very much for your help
Thank you very much for your help