Blinking a LED

Getting a LED to blink on a chip evaluation board is often one of the first steps an engineer takes in evaluating and becoming familiar with a microcontroller. All Microcontrollers allow you to toggle GPIO or General Purpose Input Output pins either high or low. These generic pins can be configured either as an input (read) or output (write). A high signal is usually referenced as a "1" and a low signal a "0". The input and output voltage range is usually limited to the supply voltage.

= Usage = Getting a high or low signal out to the physical pin requires accessing the pin via ports within the Microcontroller. The pin itself is nearly always multiplexed with other internal signals using a MUX, so it is important to make sure that you have properly configured the pin as an output using the associated configuration registers. Some IDE's like the Arduino abstract this process, while other production level chips such as the Freescale K40 require direct register configuration. The same GPIO used for blinking an LED can be re purposed to read a signal coming from an external device, or to create interrupts for tracking something like the input from a hall effect sensor. We use GPIO configuration and "bit-blasting" to control the Line Scan Camera.

=Read/Write= In write mode, the GPIO pin can be set, cleared, or toggled via software initiated register settings.

For example, to toggle a pin: "Sets" the LED located at "E1" high.

"Set" is one of three commonly utilized commands for GPIO control. There are also commands for "Clear" and "Toggle."

If the LED was on Port C, Bit 7 we might have code like:
 * Command: "GPIOC_PSOR" sets a pin high
 * Command: "GPIOC_PCOR" clears a pin, setting it low
 * Command: "GPIOC_PTOR" toggles a pin opposite of the current state

the << is a "shift" command which is discussed in the C Refresher Course. You can alter the raw register as well using a MASK but the dedicated set/clear/toggle registers are more straightforward.

=Microcontroller Reference Manual: GPIO Information=

You will find high level information about GPIO usage in several different areas of a reference manual. See the Reference Manual article for more specific information on how best to navigate through to the areas which are relevant.


 * Relevant Chapters:
 * System Modules: System Integration Modules (SIM) which provides system control and chip configuration registers
 * Chip Configuration: under Human-Machine interfaces (HMI).
 * Signal Multiplexing under Port control and interrupts
 * Human-Machine Interfaces: under General purpose input/output

Please follow the links below for microcontroller specific code an instructions.

= Microcontroller Example Code =

LED Blink: Kinetis ARM Cortex M4
The K40 chip has (n) GPIO pins which are on ports (x-y). Specifics of how to configure these pins and create delay code is covered in the Blink an LED on a Kinetis Chip section.

LED Blink: Quorriva
=Hardware=

LED Circuit
The circuits provided on typical evaluation boards are...

pull up / down - with resistor diagram, voltage and current discussion

Creating your own led circuit
The Pololu TReX Jr Motor Controller is a powerful multi-functional motor controller ideal for table-top robotics. Though it is larger than the dual serial motor controller from Pololu, it is much more sturdy and can drive a range of powerful DC motors.