Hi Mircea, Could you please spell "Hi" correctly? :) Thanks, Tamas Sent from my iPhone On Jun 22, 2013, at 11:57 AM, Bob Blick wrote: > added tag. -Bob > > On Sat, Jun 22, 2013, at 11:42 AM, mircea2012 wrote: >> Hy. >> In this program i try to test compare mode using pic16f88. >> I am not quite sure if it is OK but the code is working. >> I set an output RB0 for 1 sec (led is ON), after that i reset that outpu= t >> RB0 (led is OFF) for 1 sec. >>> From my calculations : f =3D 4MHz / (4 * 8 * 65536) =3D 2Hz >> T =3D 1 / 2Hz =3D 0,5 which means that the led is on twice per sec. >> But in program i use variable counter to increase the delay, so led is o= n >> for 1 sec and off - 1 sec. >> >> >> #include >> >> #pragma DATA _CONFIG1, _EXTRC_CLKOUT & _WDT_OFF & _LVP_OFF >> >> unsigned int counter =3D 0; >> >> void interrupt() >> { >> if((pir1 & 0x01) && (pir1 & 0x04)) >> { >> clear_bit(pir1, 0); >> clear_bit(pir1, 2); >> counter++; >> if(counter =3D=3D 2) >> { >> ccp1con =3D 0b00001001; >> } >> else if(counter =3D=3D 4) >> { >> ccp1con =3D 0b00001000; >> counter =3D 0; >> } >> } >> } >> >> void main() >> { >> trisb =3D 0xf0; >> portb =3D 0x00; >> tmr1h =3D 0; >> tmr1l =3D 0; >> ccpr1l =3D 0x60; >> ccpr1h =3D 0xea; >> cmcon =3D 0x07; >> t1con =3D 0b00110001; // prescaler =3D 8 >> intcon =3D 0b11000000; >> pie1 =3D 0b00000101; >> ccp1con =3D 0b00001000; >> while(1) >> { >> >> } >> } > > -- > http://www.fastmail.fm - Access your email from home and the web > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=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 .