User manual
LPCXpresso Experiment Kit - User’s Guide
Page 93
Copyright 2013 © Embedded Artists AB
7.13.5 Lab 12e: Control Dual Digit 7-segment Display
This experiment revisits Lab 8d: Control Dual Digit 7-segment Display and Lab 11b: Control 7-segment
Display. By combining the knowledge from all previous experiments it is now possible to create a
system that is quite close to a how this would have been solved in a real system.
Setup a repetitive timer interrupt, say 500 Hz (2 ms between each interrupt). Let the timer ISR update
the dual 7-segment display. The ISR alternates which digit that is updated.
The main program just set up the timer ISR and writes the segment outputs in a global variable (that
the timer ISR can read when updating the digits).
The suggested program structure for the timer ISR is presented in the code block below.
/* Declare variable to store digit outputs */
volatile uint8_t digitSegments[2];
/* Define Interrupt Service Routine for 32-bit timer #1 */
void TIMER32_1_IRQHandler (void) //name of function is predefined
{
//counter that indicate active digit (numbered 0 and 1)
static uint8_t activeDigit;
if (activeDigit == 0)
{
//Disconnect anode of digit #0 (pull control signal high)
...
//Send segment outputs (via SPI) for digit 1
...
//Connect anode of digit #1 (pull control signal low)
...
activeDigit = 1;
}
else
{
//Disconnect anode of digit #1 (pull control signal high)
...
//Send segment outputs (via SPI) for digit 0
...
//Connect anode of digit #0 (pull control signal low)
...
activeDigit = 0;
}
//clear interrupt
...
}