Microcontrollers use memory maps in order to control the various ports it has on the board. Each pin has multiple registers that controls its behavior such as whether it’s an input/output, whether the internal resistor is enabled and if it’s a pull-up/down resistor.
- Configure the onboard button to be an input.
- Configure the onboard LED to be an output.
- Program the microcontroller using assembly to turn on/off the LED through the button.
Using assembly really gives you a better idea of how microcontrollers work and how C has abstracted away a lot of the work that you have to go through. This whole lab would have only been a couple lines using an Arduino but through assembly, there are a lot more things to consider.
The ports on the microcontroller are mapped to registers that can be altered through code which in turn will control how the ports work and the devices attached to them.
BIC: Clears the bit to 0
BIS: Sets the bit to 1
BIT: Tests the bit
$P1DIR: Controls whether the port is an input (0) or an output (1).
$P1REN: Enables the internal resistor for an input. $P1OUT = 0 (Pull-down), $P1OUT = 1 (Pull-up).