The most basic thing to do with a microcontroller is to operate it’s GPIO pins. To use a PIN on a DipCortex (LPC11U/LPC1347) or SolderBridge (LPC11U24) as a GPIO you have to consider the following,
- What peripherals are on this pin, it may not default to be a GPIO pin (most do)
- What features of the pin do I want to enable/disable. Pull ups, Pull downs, Invert, Analogue input etc..
- Do I want an input or an output
- Is the pin 5v tolerant
First download the User manual it has all the info you need. It is quite large but has the answer to almost all questions when it comes to using the LPC.
Step 1 – Configure The Pin’s Function
Select your pin and examine its description in chapter 8. Here you will find what peripherals the pin has and if it is 5v tolerant. To configure the pins mode, the periperhal in charge of it, you modify the value in the IOCON register associated with it.
For example lets pick Port1 Pin 13 – Referred to as PIO1_13. Section of 18.104.22.168 of the user manual details the function of each bit in this register and what value each bit will be at reset.
If I wanted to use it as a GPIO, with a pull up enabled and Hysteresis (Ignores noise, good for button inputs) I would do the following :
Step 2 – Set The Direction
All micro-controllers use the concept of direction when referring to a GPIO Pin it’s either an Input or an Output. For ARM processors a set bit indicates it’s an output and a clear bit an input.
Step 3 – Use the Pin
To read the GPIO Pin there are a few different options :
If it’s an output you can write to the SET and CLR registers to modify only a single pin, leaving other outputs alone