Develop a realtime interrupt RTI driven change of LED light
Develop a real-time interrupt (RTI) driven change of LED light pattern display on the Dragon 12-Plus demo board. You need to write a C program to light up one LED at a time starting from the one driven by PORT B pin 7 till the one driven by PORT B pin 0 and then reverse the order of LED lighting. Repeat this operation forever. Each LED should be lighted for about 500 ms assuming that the HCS12 uses an 8-MHz crystal oscillator to generate a system clock.
Solution
void INTERRUPT timer6(void) {
TFLG1 &= 0x40; // Next interrupt in 500ms
TC6 += TB500MS;
__asm__ __volatile__ (\" cli \"); /* Enable interrupts */
select = (select+1) & 3; // Go to next digit
PORTB = 0; // While we change, at least, we want display off
if (ledFraction + ADR00H > 255) { // display
PTP = (PTP & 0xf0) | dspmap[select];
if ((PTH & PB_MASK & ~ALARM_SW) == 0) { // Display Alarm Value
PORTB = segm_ptrn[dispa[select]] | dispadp[select];
} else { // Display current value
PORTB = segm_ptrn[dispt[select]] | disptdp[select];
}
}
if (select==0) ledFraction += ADR00H; // Save updated fraction
}
