#include<htc.h>
__CONFIG(0x3D18);
unsigned char toggle;
unsigned char Ontime, Offtime;
void interrupt ISR()
{
if(TMR0IF)
{
toggle= ~toggle;
if(toggle)
TMR0 = Ontime;
else
TMR0 = Offtime;
RA0 = toggle;
TMR0IF = 0;
}
}
void main()
{
TRISA0 = 0;
TRISB = 0xff;
TMR0IE = 1;
TMR0 = 0xff - 34;
GIE = 1;
Ontime = 0xff - 34;
Offtime = Ontime;
while(1)
{
if(!RB0 && (Ontime > (0xff - 66)))
{
Ontime--;
Offtime++;
}
if(!RB1 && (Ontime < (0xff - 2)))
{
Ontime++;
Offtime--;
}
}
}