7 years ago.

PortOut of different ports

I have read that PortOut is faster than BusOut. In the past I have used PortOut and PortIn, so I understand the basics(asigning to a port and using a mask to select some pins,etc)

However so far I have used all pins of a PortOut or PortIn being part of a Port, for example Port A pins 9,10,11,12

#define MASK (0x1E00) // the pins above defined
PortOut stepMotor(PortA,MASK);

What happens if I want to have a PortOut defined as for example PortA pins 9,10 and PortB pins 11, 12? Is this even possible??

(I would like that all in a variable such as stepMotor above

1 Answer

7 years ago.

BusOut provides the same interface for a custom port like output, while PortOut is a real, hardware port. So you can not mix pins from different ports in PortOut.

"Use the PortOut interface to write to an underlying GPIO port as one value. This is much faster than BusOut because you can write a port in one go, but it is much less flexible because you are constrained by the port and bit layout of the underlying GPIO ports."

https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/io/PortOut/

Accepted Answer