Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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??
 

In wich programming language? Basic, C or assembly language?.
In assemler you can use the NOP instruction to make one clock cycle delay.
Another option for generating delays is assembler is to use the online Delay Code Generator:

Check this link out too: http://www.piclist.com/techref/microchip/delays.htm
 

Goto MCU server:

**broken link removed**

And download the file "picdelay.zip" at the bottom of the page.

Best regards
 

tnx for the posts and linx guys. :)

/ Warning #1 - No thanks at elektroda. Read forum rules before you post! **broken link removed**
 

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.
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top