Pyro Propeller Clock POV

The Software
           There are two main portions of code that we are concerned with:
    -High Priority RB0 Interrupt
    -Low Priority Timer0 Interrupt

I'll describe these two parts of the software in the two sections found below.


High Priority RB0 Interrupt

------------« Begin Code »------------
void InterruptHandlerHigh()
{
   if(INTCONbits.INT0IF) //check if INT0 interrupt flag is set
   {
     led_count = 325;
     WriteTimer0( 0xFFE0 );
     INTCONbits.TMR0IF = 0; //Clear TMR0 Flag
     INTCONbits.INT0IF = 0;
   }
INTCONbits.GIEH = 1;
}
------------« End Code »------------

           The job of this high priority interrupt is to reset the timer0 so that it starts outputting to the LEDs from the very beginning. This is how the POV effect is created, by displaying the same pattern over and over many times per second. The led_count variable seen above is used as a timer interrupt counter to know which set of LED information to output. In the INT0 interrupt service routine it also gets reset.

Low Priority Timer0 Interrupt

------------« Begin Code »------------
void InterruptHandlerLow()
{
   if(INTCONbits.TMR0IF) //check if TMR0 interrupt flag is set
   {
     WriteTimer0( 0xFE49 ); //Reset Timer0 for 43.8uS Delay
     //Set The Clock Numbers On Top
     if(led_count < 0x11D && led_count > 0x117){
     ...
     ..
     ...
     ..
     ..
     }
     else{
     set_leds(0xFFFF);
     }
     INTCONbits.TMR0IF = 0; //Clear TMR0 Flag
   }
INTCONbits.GIEL = 1; //Re-enable all interrupts
}
------------« End Code »------------

           The timer0 interrupt service routine decrements the led_count value and then uses it to dynamically know which leds to turn on and off. A big set of if/else statements were used for different locations and clock numbers/text that show up on the display.



;