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.

1 sec delay using 16F877A

Status
Not open for further replies.

crazyramila

Newbie level 6
Joined
Jan 11, 2011
Messages
13
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,360
cn i know how to create 1 second delay using 16F877A???
i want to do this in Assembly language!
please help me to come up with this....
 

Code:
;At 4.0Mhz, delay = approx. 100mS.
delay_100ms:
				movwf	CounterY		;
dly3:			call	delay10mS		;
				clrwdt
				decfsz  CounterY, F 	;
				goto	dly3			;	
				return					;

delay10mS:		clrf	CounterX		; 10022uS (( 39 * X ) + 39 ) = uSec.
				comf	CounterX,f		;
				goto	dly1			;

delay2mS:		clrf	CounterX
dly4:			call	dly5			;
				decfsz  CounterX, F 	; reduce count (( 7 * X ) + 4 ) = 1028 => 1,028 mSec39 * X ) + 37 ) = uSec.
				goto    dly4            ; loop
dly5:			return					;

delay1200uS:	clrf	CounterX		; 1207uS (( 39 * X ) + 37 ) = uSec.
				bsf		CounterX,5		;
				decf	CounterX,f		;
				decf	CounterX,f		; = d'30'
				goto	dly1			;

delay800uS:		clrf	CounterX		; 895uS (( 39 * X ) + 37 ) = uSec.
				bsf		CounterX,1		;
				bsf		CounterX,4		;
				decf	CounterX,f		; = d'20'

dly1:			call	dly2			;
				decfsz  CounterX, F 	; reduce count (( 39 * X ) + 37 ) = uSec.
				goto    dly1            ; loop
dly2:			goto	$+1				; 1
				goto	$+1				; 2
				goto	$+1				; 3
				goto	$+1				; 4
				goto	$+1				; 5
				goto	$+1				; 6
				goto	$+1				; 7
				goto	$+1				; 8
				goto	$+1				; 9
				goto	$+1				;10
				goto	$+1				;11
				goto	$+1				;12
				goto	$+1				;13
				goto	$+1				;14
				goto	$+1				;15
				goto	$+1				;16
				return					;
 
i dnt know C language
cn u help me to do this in Assembly language?
 

movlw 0x07
movwf count1
movlw 0x19
movwf count2
movlw 0x06
movwf count3

delay
decfsz count1,1
goto delay
decfsz count2,1
goto delay
decfsz count3,1
goto delay
return
 

Hi,

That looks good, you can use MPlabs Debugger,Mplab Sim, Stop Watch to check the timing accuracy.

Once you understand the principle of the delay routine you can use sites like this to save you working it out for yourself.
**broken link removed**
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top