8 years ago.

BusOut

I am using BusOut to create an 8-bit bus on a LPC824 and it works fine. However, there appears to be no instructions to define the direction (input or output), initial state, mask bits,etc - all we have is a call to BusOut which is inside an endless loop. Does this mean that the port pins are initialised every time the BusOut is called? If not, how and where is the initialisation acheived? There is a similar example in LPCXpresso and there are calls to: -

/* Set selected port 0 pins on 824 to the output direction*/ Chip_GPIO_SetPortDIROutput(LPC_GPIO_PORT, 0, PORT_MASK);

/* Set GPIO port mask value to make sure only selected pins are active during state change */ Chip_GPIO_SetPortMask(LPC_GPIO_PORT, 0, PORT_MASK);

Why such a difference?

1 Answer

8 years ago.

Setting initial state, Direction etc is all taken care of (and hidden for the user) in the BusOut class. So similar methods like the ones you have mentioned above are executed under the hood. I would not declare the BusOut variable inside a loop since then all that initialisation is done over and over again. Declare it once outside the loop and then just assign values to it inside the loop.

See the handbook examples for BusOut and/or PortOut here.

Accepted Answer