Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic timer questions

Status
Not open for further replies.

Lilikin

New Member
where do i find the commands that let me set the timer on the 877 the data sheetr talks around the subject and the generic commands dont say either any ideas??

i need to count then stop the count on an external int and output the count to a port

also where is the config settings given per device i cant seem to see them

also the does rs232 need to receive answers from anther device i want to get a pic to talk to two devices well listen to one and speak and listen to another will this work i know the one it listens to only can work on its own but how would i get it just to carry it commands
 
There are no specific 'commands' for setting up the timer, the datasheet specifies the registers with which you need to fill with your settings using standard instructions, for example T1CON for configuring Timer1 and T2CON for configuring Timer2, each timer module should have it's own section in the datasheet.

So, you could run the timer, and have your external interrupt trigger your ISR, in which you could stop the timer and then you could do what you wanted with the contents of the count register (TMR1L & TMR1H or TMR2, for Timer1 and Timer2 respectively).

Hope this helps.
 
given below are the settings for pic16f877.hope this helps u.also the interrupt routine u need .


Code:
LIST	p=16F877A, W=2, X=ON, R=DEC	;tell assembler what chip we are using
	include "P16F877A.inc"			;include the defaults for the chip
	ERRORLEVEL	0,	-302		;suppress bank selection messages
	__CONFIG    0x393A			;sets the configuration settings (oscillator type etc.)


		cblock	0x20	
.
.
.
.
.
.
.
.
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>frequency call>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

		ORG	0x0004
		
		MOVWF 	w_temp 		; save off current W register contents
		MOVF 	STATUS,w 		; move status register into W register
		MOVWF 	status_temp 	; save off contents of STATUS register
		
		BTFSC	T1CON, TMR1ON
		goto	Stop_timer1
		
		CLRF	TMR1H
		CLRF	TMR1L
		BSF		T1CON, TMR1ON
		GOTO	END_ANS_INT


Stop_timer1
		BCF		T1CON, TMR1ON
		MOVF	TMR1H, W
		MOVWF	TIMER1_HIGH
		MOVF	TMR1L, W
		MOVWF	TIMER1_LOW
		BSF		freq_over, 0X00
		
		;BCF		INTCON, INTE
END_ANS_INT		
		MOVF 	status_temp,w 	; retrieve copy of STATUS register
		MOVWF 	STATUS 		; restore pre-isr STATUS register contents
		SWAPF 	w_temp,f
		SWAPF 	w_temp,w 		; restore pre-isr W register contents              	
		BCF		INTCON, INTF
		
		retfie
;=====================================================================
 
no rs232 doesnot need to wait for other device it is up to u if u want to check that is communication goin on
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top