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.

Led blinking using timer 0 of PIC

Status
Not open for further replies.

sush

Member level 4
Joined
Aug 24, 2005
Messages
78
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,946
Led Blink using PIC

hi friends,
can anyone please help me in finding out myh mistake. Actually i'm trying to blink a led using timer 0 of PIC16F628A but can't. here's the code:-

Code:
	LIST	p=16F628A		;tell assembler what chip we are using
	include "P16F628A.inc"		;include the defaults for the chip


	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb 			;used in delay routine
	endc
	
	org	0x0000				;org sets the origin, 0x0000 for the 16F628,
		GOTO	start					;this is where the program starts running	


	org	0x04						GOTO	OVFL_ISR					;this is where the ISR starts running	



	movlw	0x07
	movwf	CMCON			;turn comparators off (make it like a 16F84)




initialize
	clrf       PORTB   

	bsf 	STATUS,	RP0		;select bank 1
   	movlw 	b'00000000'		;set PortB all outputs
   	movwf 	TRISB
	
	bcf		STATUS,	RP0		;select bank 0
	retlw	0x00



OVFL_ISR
	
	comf	PORTB, F
	bcf		INTCON, T0IE
	retfie





start
	call	initialize
	
	clrf	TMR0
	clrf	INTCON
	bsf 	STATUS,	RP0		;select bank 1
	movlw 	b'00110001'
	bsf		INTCON, T0IE
	bsf		INTCON, GIE


Loop	
	
	goto	Loop			;go back and do it again



	end

i would appretiate any help, Thank you.
 

alzomor

Advanced Member level 2
Joined
Jun 9, 2005
Messages
678
Helped
39
Reputation
78
Reaction score
8
Trophy points
1,298
Location
Cairo
Activity points
6,417
Re: Led Blink using PIC

Hi

Excuse me, where do you configure your timer.
dose the timer need reloading within each interrupt

Salam
Hossam Alzomor
www.i-g.org
 

UroBoros

Advanced Member level 2
Joined
May 5, 2004
Messages
642
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Location
Cochin - India
Activity points
6,457
Re: Led Blink using PIC

Hai

I think you forgot to return to Bank0 after going to bank1.

INTCON is available in all banks.So no need to switch banks.

go to OPTION register and set Timer0 speed before enabling interupt.


Another suggession

Better not to start with interrupt .Use delay first for timing .Then move to Interrupt

Only a preference

picstudent
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top