Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

PIC instruction delays - general formula?

Status
Not open for further replies.

jetsam

Newbie level 3
Joined
Apr 16, 2003
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
74
instruction delays

does anyone have a general formula for making PIC instruction delays??
 

ME

Advanced Member level 4
Joined
Mar 14, 2002
Messages
1,309
Helped
55
Reputation
112
Reaction score
40
Trophy points
1,328
Activity points
14,861

OskarDust

Newbie level 4
Joined
Apr 14, 2003
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
65
Re: PIC instruction delays

Delay libraries use a big amount of ROM code. Simply use NOP and nested loops and try it with a osciloscope.
 

SphinX

Advanced Member level 3
Joined
Jan 25, 2002
Messages
822
Helped
58
Reputation
116
Reaction score
29
Trophy points
1,308
Location
EGYPT
Activity points
7,051
Hi,

Use this routine.

ncount equ 0x0c
mcount equ 0x0d
;
pause movlw 0x__ ; M
movwf mcount
loadn movlw 0x__ ; N
movwf ncount
decn decfsz ncount,f
goto decn
decfsz mcount,f
goto loadn
return

Total cycles = 3MN

Example

To generate 12 ms delay ( with 4 Mhz Xtal)

M=N=Y
so 3Y^2=12000 us

so Y^2= 12000/3= 4000
so Y = Sqrt(40000) = 63.2 decimal = 0x3f

so M=N=0x3f

Bye
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top