Direct Write to Digital GPIO Pin

Good Day,

Does anyone know how to write directly to a GPIO register on Photon 2? Similar to Arduino Nano's PORTB = 0b00001000 for example. I'm trying to write to D2.

I am aware the digitalWrite function exists.

Thank you,
Matt

We don't recommend doing that. If you really want to know, look in the device-os Github repository in hal/src/rtl872x/gpio_hal.cpp.

Also, it will not be any faster. The limiting factor for P2/Photon 2 is the peripheral clock speed, not the overhead of the extra code in digitalWrite. The 200 MHz KM4 MCU in the RTL872x is more than fast enough to do the overhead calculations, but the GPIO will still be slow.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.