??? 06/26/05 01:18 Read: times |
#95926 - Code I'm using Responding to: ???'s previous message |
Russel, thanks for the quick reply! Below is the latest iteration of my code. Thanks for the kudos Andy! I try to be thorough.
Code: #include <at89x51.h> #define ON 1 #define OFF 0 #define HIGH 1 #define LOW 0 void Timer0_ISR (void) interrupt 1; // ISR for Timer0 overflow void Timer0_ISR (void) interrupt 1 { if(F0 == LOW) { /* Just finished the LOW period, switching to HIGH */ F0 = HIGH; P1_0 = OFF; /* Turning on P1_0 */ TH0 = 0xFA; /* Setting timer start value to 64245 */ TL0 = 0xF5; TF0 = 0; /* Reset Timer Overflow Flag */ } else { /* Just finished the HIGH period, switching to LOW */ F0 = LOW ; P1_0 = ON; /* Turning off P1_0 */ TH0 = 0xC3; /* Setting initial timer value to 50068 */ TL0 = 0x94; TF0 = 0; /* Reset Timer Overflow Flag */ } return; } void main (void) { EA = ON; /* Enabling All Interrupts */ ET0 = ON; /* Enabling Timer 0 Interrupt */ TR0 = 0; /* Stop Timer 0 */ TF0 = 0; /* Reset Timer Overflow flag */ TMOD &= 0xF0; /* Set Timer 0 to Mode 1 (16-bit no prescalar) */ TMOD |= 0x01; /* Set Timer 0 to Mode 1 (16-bit no prescalar) */ TH0 = 0xC3; /* Setting initial timer value to 50068 (i.e. LOW period) */ TL0 = 0x94; F0 = HIGH; /* Setting F0 Flag to HIGH */ P1_0 = OFF; /* Turning off P1_0 */ TR0 = 1; /* Starting Timer 0 */ while (1) { } } |