Hi, without changing the way you have started to write your code, here is a qui= ck fix for you. void interrupt()=20 {=20 if(intcon & 0x04)=20 {=20 clear_bit(intcon, 2);=20 counter++;=20 =09 if(portb =3D=3D 1) { if(counter =3D=3D 3906) { portb =3D 0; } } else { if(counter =3D=3D 2929) { portb =3D 1; } } counter =3D 0; }=20 } -Jim On Fri 21/06/13 10:22 AM , mircea2012 mircead.personal@yahoo.com sent: > Hy. > I want to generate two diferent delays, using timer0 pic16f88. > step 1 : led 1 stay ON 4 sec > step 2 : led 1 stay OFF 3 sec >=20 > By the way I use a Matrix multimedia development board. >=20 > Look at my cod : in this moment the led 1 stay ON - 4 sec and then stay > OFF- 4 sec. > I know that my mistake is in interrupt function, but i am not able to > correct this mistake.=20 >=20 > #include=20 > #pragma DATA _CONFIG1, _EXTRC_CLKOUT & _WDT_OFF & _LVP_OFF >=20 > unsigned int counter=3D0; >=20 > void interrupt()=20 > { =20 > if(intcon & 0x04) =20 > { =20 > clear_bit(intcon, 2);=20 > counter++; =20 > if(counter =3D=3D 3906) =20 > { > portb =3D ~portb; > counter=3D0; > } > } =20 > } >=20 > void main() > { > trisb =3D 0xf0; > portb =3D 0; > tmr0 =3D 0; > cmcon =3D 0x07; > option_reg =3D 0b00000001; // prescaler =3D 4 > intcon =3D 0b10100000; > while(1) > { >=20 > }=20 > } >=20 >=20 >=20 > -- > View this message in context: http://microcontrollers.2385.n7.nabble.com/= PIC-TIMER0-delay-tp1 > 83408.htmlSent from the MicroControllers - PIC mailing list archive at > Nabble.com.--=20 >=20 > http://www.piclist.com/techref/piclist PIC/SX > FAQ & list archiveView/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist >=20 >=20 --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .