Sorry, I forgot to mention, this is with the 20 MHZ clock mentioned earlier= .. Allen > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of > Allen Mulvey > Sent: Friday, July 18, 2014 10:40 AM > To: 'Microcontroller discussion list - Public.' > Subject: RE: [Pic] Making a special timer! >=20 > MikroElektronika has a free Timer Calculator that you can use to get the > code to set up your timer. I don't understand why anyone would want to us= e a > PWM when the timer is so easy and quite accurate. Check this out: > http://www.libstock.com/projects/view/398/timer-calculator >=20 > I use it all the time. For a PIC16 Timer1 you can get 100ms from this code: >=20 > //Timer1 > //Prescaler 1:8; TMR1 Preload =3D 3036; Actual Interrupt Time : 100 ms >=20 > //Place/Copy this part in declaration section > void InitTimer1(){ > T1CON =3D 0x31; > TMR1IF_bit =3D 0; > TMR1H =3D 0x0B; > TMR1L =3D 0xDC; > TMR1IE_bit =3D 1; > INTCON =3D 0xC0; > } >=20 > void Interrupt(){ > if (TMR1IF_bit){ > TMR1IF_bit =3D 0; > TMR1H =3D 0x0B; > TMR1L =3D 0xDC; > //Enter your code here > } > } >=20 > Enable the interrupt. Turn on your pin. Count 10 interrupts. Turn off pin= .. > Turn off and reset timer. Start over when necessary. >=20 > You may need to make minor adjustments (TMR1L) for the time to actually turn > the pin on and off. >=20 > Allen >=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 .