
218 CHAPTER 12. PROJECT 3: PEAK PROGRAM METER
27 if ( LED_2_counter ) {
LED_2_counter −−;
29 workingLedMask |= LED2_BIT ; // LED2 on
}
31
if ( LED_1_counter ) {
33 LED_1_counter −−;
workingLedMask |= LED1_BIT ; // LED1 on
35 }
37 LedMask = workingLedMask ; // update LED mask for main ()
An explanation of Listing 12.3 follows.
1. (Lines 1–3): Determines maxOutput (the maximum of the absolute value of both the
left and right output channels).
2. (Lines 5–9): If maxOutput is greater than 32,767 in magnitude, then LEDs 1, 2, and 3
are turned on. Counters for LED 1, 2, and 3 are set at 14400, 9600, and 4800. These
counter values keep LEDs 1, 2, and 3 “ON” for