Or check out PIClist's Techref delay generator: http://www.piclist.com/techref/piclist/codegen/delay.htm That generates the following code for 10ms delay on a 4 MHz FOSC: ; Delay =3D 0.01 seconds ; Clock frequency =3D 4 MHz ; Actual delay =3D 0.01 seconds =3D 10000 cycles ; Error =3D 0 % cblock d1 d2 endc Delay ;9993 cycles movlw 0xCE movwf d1 movlw 0x08 movwf d2 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto Delay_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return Tamas On 29 June 2013 06:42, Allen Mulvey wrote: > You might want to check out the MikroElektronica timer > calculator. It is free. Just specify which PIC you are using > and the time you want and it will give all the necessary > settings. > > http://www.libstock.com/projects/view/398/timer-calculator > > Allen > > > -----Original Message----- > > From: piclist-bounces@mit.edu [mailto:piclist- > > bounces@mit.edu] On Behalf Of Electronic Consultation > > Sent: Saturday, June 29, 2013 6:44 AM > > To: Microcontroller discussion list - Public. > > Subject: Re: [PIC]Counter in PIC > > > > Is my counter will give me the right 10ms ? > > > > ;********************************************* > > ************************* > > ; 10ms timer function calls > > ;********************************************* > > ************************* > > ;....... 10ms timer counter here..... > > timer10ms > > movf 0x0A > > btfsc STATUS,Z > > goto timer10ms > > > > > > ;.................................... > > > > incf COUNT1, f > > movlw .10 ;Compare count to 100 decimal > > subwf COUNT1, W ;Store the result back in > > btfss STATUS, C ;Is the result 0, skip if > no > > goto exittimer > > clrf COUNT1 > > On 29/06/2013 1:45 PM, eCHIP wrote: > > > If you need a 100 mS delay with a 4 MHz PICmicro, below > is > > the code. > > > > > > delay1mS movlw .250 > > > movwf temp1 > > > clrwdt > > > decfsz temp1,f > > > goto $-2 > > > retlw 00 > > > > > > > > > delay100ms movlw .100 > > > movwf temp > > > call delay1ms > > > decfsz temp,f > > > goto $-2 > > > retlw 00 > > > > > > Cheers > > > > > > Ravi > > > > > > > > >> Hi, when you post to the Piclist you need to put an > > appropriate topic > > >> tag in the subject line. This time I have added one to > your > > message. Bob > > >> > > >> On Fri, Jun 28, 2013, at 10:04 PM, Electronic > Consultation > > wrote: > > >>> Guys, > > >>> > > >>> Am I creating a right counter for PIC ? > > >>> > > >>> timer100ms > > >>> movlw 0x64 > > >>> movwf COUNT1 > > >>> decfsz COUNT1 > > >>> return > > >>> > > >>> thanks > > > > -- > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list > > archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > 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 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=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 .