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.

Delay function 4 seconds for pic 16f877A 20MHZ,, Assembly,,, help please!

Status
Not open for further replies.

real289

Newbie level 2
Joined
Oct 26, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hello everyone!

This is my first thread in the forum, I am really glad to have found it, its very helpful :D

I am just a beginner, and I want to find the correct function for the 16f877A to make a 4 seconds delay with 20MHZ

Thanks a lot :)
 

Hi and Welcome,

Use this very handy delay code generator, if you get stuck come on back.
Remember that 1 machine cycle ( the time for most instructions) is the Crystal Frequency /4


**broken link removed**

Code:
; Delay = 4 seconds
; Clock frequency = 20 MHz

; Actual delay = 4 seconds = 20000000 cycles
; Error = 0 %

	cblock
	d1
	d2
	d3
	endc

Delay
			;19999992 cycles
	movlw	0xB5
	movwf	d1
	movlw	0x99
	movwf	d2
	movlw	0x2C
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;4 cycles
	goto	$+1
	goto	$+1

			;4 cycles (including call)
	return
 

Thanks a lot

I tried this but I want the delay using the "nop" instruction and by having counters. Is this possible? Thanks a lot
 

Hi,

A delay using the NOP is just for one instruction, for your 4 seconds you need 20 million of them !
That is basically what that delay routine is doing, just that each loop takes several instructions, so it only needs counters d1,2 & 3

If you mean a delay using the Pics Timers ? - then see this first turorial, one of several good online ones.

**broken link removed**

Nigel's PIC Tutorial Page
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top