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.

[SOLVED] using timer registers.

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
hi im new to this subject,
i implmnt a small circuit using 16F877A


LIST p=16F877A
#include p16F877A.inc
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC & _LVP_OFF

STATUS equ h'03'
PORTA equ h'05'
TRISA equ h'85'

;*********shange the bank************
bsf STATUS,5
bcf PORTA,0
bcf STATUS,5

main
;*********bulb on*************
bsf PORTA,0

;*********bulb on*************
bcf PORTA,0

goto main
end



now i want to reduce the speed of this process without using delay loops
can any 1 help me to do that using TMRO.....?????
 

how long for the delay off and on?
What speed is your pic running at?

This information is required to work out the prescalers of the TMR0.
 
30sec delay
n
speed 4MHz

---------- Post added at 15:31 ---------- Previous post was at 15:30 ----------

30sec delay
n
speed 4MHz
 

Here is some code I will mod it in a short while for the delays, it will give you an idea of how to do it.

Code:
LED	equ 0x20	;variable for led
temp_s	equ 0x21
temp_w	equ 0x22


	goto start
	ORG 0x0004 


isr_routine
	movwf	temp_w		;save the contents of W
	movf	Status,W	;Move status to W	
	movwf	temp_s		;save the status register

;setup the next interrupt
	movwf	.99	
	movwf	TMR0

	movlw	b'1'		; here we xor the contents of LED and save
	xorwf	LED,1
	movfw	LED
	movwf	porta		;switch the led

ExitISR
	bcf		intcon,T0IF
	movf	temp_s,w
	movwf	status
	swapf	temp_w,f
	swapf	temp_w,w
	retfie

Start
	banksel	trisa
	clrf	trisa
	banksel	porta
	clrf	porta
	clrf	LED

;setup the interrupts
	movlw	b'10000001'		;set up prescaler etc
	banksel	trisa
	movwf	option_reg
	bsf		intcon,7
	bsf		intcon,5
	banksel	porta

doloop
	goto $
	

end
 
thank you for your prompt response
i really appreciate it
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top