void interrupt() {
if(TMR0IF){
PORTA.B0 = ~PORTA.B0; //troca o valor de PORTA.B0
TMR0L = 135;
TMR0IF_bit = 0; //reset flag
}
}
void main() {
TRISA = 0b00000000; //defiine PORT-A como saida
PORTA = 0b00000000; //coloca todos os pinos a zero
OSCCON = 0b00000010; //Oscilador interno a 31 Khz
ADCON1 = 0x0F; // Configura pinos AD como digital
CMCON = 0x07; // Comparador off
T0CON.TMR0ON = 1;// Timer0 On/Off Control bit:1=Enables Timer0 / 0=Stops Timer0
T0CON.T08BIT = 1;// Timer0 8-bit/16-bit Control bit: 1=8-bit timer/counter / 0=16-bit timer/counter
T0CON.T0CS = 0;// TMR0 Clock Source Select bit: 0=Internal Clock (CLKO) / 1=Transition on T0CKI pin
T0CON.T0SE = 0;// TMR0 Source Edge Select bit: 0=low/high / 1=high/low
T0CON.PSA = 0;// Prescaler Assignment bit: 0=Prescaler is assigned; 1=NOT assigned/bypassed
T0CON.T0PS2 = 1;// bits 2-0 PS2:PS0: Prescaler Select bits
T0CON.T0PS1 = 0;
T0CON.T0PS0 = 1;
TMR0L = 135; // preset for Timer0 LSB register(1 cycle adjusted)
INTCON.TMR0IE = 1; //TMR0 Overflow Interrupt Enable bit
INTCON.GIE = 1; //Global Interrupt Enable bit
while(1);
}