Is there a way to have 6 different GPIOs act in unison off one event/action? I need all 6 to go ON and OFF at EXACTLY the same time based of an event or action.
Is there a way to have 6 different GPIOs act in unison off one event/action? I need all 6 to go ON and OFF at EXACTLY the same time based of an event or action.
Hi Brian
The easiest way to do this is to write directly to the OUT, OUTSET or OUTCLR registers in the GPIO module. The last two in particular makes it very easy to set or clear multiple pins at the same time, simply by writing a pin mask into the register.
As an example, this code sets P0.02 and P0.05 at the same time:
NRF_GPIO->OUTSET = (1 << 2) | (1 << 5);
Best regards
Torbjørn
Torbjørn, is there a way to do this from a PWM? For example have one channel trip 6 outputs?
Hi Brian
You can't have a single PWM channel trigger 6 outputs, but it is pretty straight forward to set up 6 individual PWM channels to trigger at the same time.
You don't mention which nRF52 device you are interested in, but the nRF52832 has 12 PWM channels in total, while the nRF52840 has 16.
You could also use 6 of the 8 GPIOTE channels to trigger 6 pins in unison, but I think the PWM is a better choice since each PWM module can handle up to 4 channels easily (with the GPIOTE you would have to fire off 6 events at the same time, versus just 2 for the PWM solution).
Best regards
Torbjørn
Torbjørn - The hardware designer connected 6 I/O pins together to try and increase the drive capability. The 6 I/O need to be driven by the PWM. Currently I have one PWM driving 4 channels (4 of the outputs), and I have the other two I/O set as disconnected inputs. I wanted to make sure all of the pins switch at the same time which is why I used only one PWM (all 4 outputs work off same clock). I would think the outputs need to switch together to avoid shorting the supply. Thanks for the help!
I am using the nRF52832