Is this correct ?Counting down is the easy part, just do
if(SystemTime_Secs > 0) SystemTime_Secs--;
in the interrupt routine.
Rich (BB code):
unsigned int SystemTime_Secs;
Rich (BB code):
/******* Interrupt Service Routine ************************/
void interrupt() {
// Used for Display Muxing.
if (TMR0IE_bit)
if (TMR0IF_bit)
{
TMR0IF_bit = 0; // Ack IRQ
TMR0 = TMR0Set; // Reset Timer0
//Display Multiplex Code goes here
if(LEDflash_timer==0) // if LED flash timer ran out
{
LEDflash_timer = LED_MUXflash_set;// reset timer and.. invert LEDs under mask
DigitsBuf[dLEDs] ^= LEDflash_mask;
}
else
LEDflash_timer--;
PORTD = DigitsBuf[dLEDs]; // 'mulitiplex' the LED display - only discrete LEDs so far
// This is where the 9 digits get selected/decoded
MUXtheDisplay(); // Run the multiplexer. When happy, move the code inline to here to save stack
}
if (CCP1IE_bit) // System Tik (dont specify Time here, it may change then this will be confusing)
if (CCP1IF_bit) // Interrupt on Timer1 = CCP
{
CCP1IF_bit = 0; // Ack IRQ
// Decrement derived timers
if (SYStik_timer_A) SYStik_timer_A--;
SecsTimerPS--; // dec Seconds timer prescaler
if(SecsTimerPS == 0) // if one second passed..
{
SecsTimerPS = SecsTimerPSset; // reload the prescaler
Sec_Elapsed = 1; // signal main program
// if(SettingTimeOut)SettingTimeOut--;// A 1 count/s incrementing counter used in T,V & I Settings
if(SystemTime_Secs>0)SystemTime_Secs--;
}
}
}
Am I on the right track ?