-
Notifications
You must be signed in to change notification settings - Fork 7
portOutputReg
gicking edited this page Feb 6, 2018
·
3 revisions
back to Command Reference / Digital-IO
Direct write access to the port output state register. This allows fast write access e.g. for parallel interfaces.
For all port pins, which have been configured as an OUTPUT
with pinMode(), writing a state drives the corresponding pin voltage: Vdd for HIGH
, 0V (ground) for LOW
.
Notes:
- after reset all I/O port pins are configured as
INPUT
- for port pins configured as
INPUT*
, writing toportOutputReg()
has no effect.
- defined in
gpio.h
- auto-loaded in
main_general.h
- no
#define
required
portOutputReg(pPort)
-
input:
- pPort: address of port you wish to set, e.g.
&PORT_D
- pPort: address of port you wish to set, e.g.
-
output:
- none
- register for setting port output states
The below code makes pins PD0..3
to output, push-pull, fast, and pins PD4..7
to input, pull-up,
no interrupt. Then toggle all output port pins HIGH
and LOW
with 1s delay.
#include "main_general.h" // board-independent main
void setup()
{
// set PD0..3 to output/push-pull/fast, and
portMode(&PORT_D, 0b00001111, 0b11111111, 0b00001111);
}
void loop()
{
portOutputReg(&PORT_D) ^= 0b1111111; // toggle PD0..3, others are inputs -> don't care
delay(1000); // wait 1s
}
- tbd
To avoid damage
- do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
- for
OUTPUT
pins assert that sink and source currents are below the specificied limits - do not directly connect two
OUTPUT
pins. If e.g. half-duplex is required, use a pull-up andOUTPUT_OPENDRAIN
, instead
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific