unsigned int num_time0;
void delay_TM0(unsigned int x)
{
OPTION_REGbits.TMR0CS=0;
OPTION_REGbits.PSA=1;
INTCONbits.T0IF=0;
INTCONbits.T0IE=1;
TMR0=0xAA;
INTCONbits.GIE=1;
num_time0=x;
while(num_time0);
}
void interrupt ISR(void)
{
if(INTCONbits.TMR0IF==1)
{
TMR0=0xAA;
INTCONbits.TMR0IF=0;
num_time0--;
}
}
|