Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
LinkBack Thread Tools Display Modes
Old 9th February 2006, 05:02 PM   (permalink)
Default code debugging

It's been a while since I last worked on my bot and I'm stuck with trying to get the TMR0 interrupt to handle the stepper pulse. The thing is...the interrupt isn't happening. Can you spot why?

Code:
Interrupt  org  0x04  	; interrupt vector 
   movwf	W_TEMP  	; 
   swapf	STATUS,W  
   movwf	S_TEMP
   bcf		STATUS,RP0
Disable_Int
   bcf		INTCON,GIE 	; 
   btfsc	INTCON,T0IF ; 
   goto		Step 	; 
;   btfsc	PIR1,TMR2IF ; 
;   goto		Left_Step 	; 

Pop    
   swapf S_TEMP,W 		; 
   movwf STATUS
   swapf W_TEMP,f
   swapf W_TEMP,w
   retfie


;****The main program*****
	#include "Bot.inc"

Start
	CLRF	PORTA			; Initialize Port A
	CLRF	PORTB			; Initialize Port B
	CLRF	PORTC			; Initialize Port C
	CLRW
	BANK1					; Select Register Bank 1
	MOVWF	TRISB			; Set B to all outputs for stepper control
	BANK0
	CLRF 	TMR0 			; Clear Timer0 register
	CLRF 	INTCON 			; Disable interrupts and clear T0IF
	BANK1
	MOVLW 	0xC7 			; PortB pull-ups are disabled,
	MOVWF 	OPTION_REG 		; Interrupt on rising edge of RB0
							; Timer0 increment from internal clock
							; with a prescaler of 1:256.
	BANK0
	BSF	INTCON, T0IE		; Enable Timer0 Interrupts
 	BSF INTCON, GIE 		; Enable all interrupts
	BSF	INTCON, PEIE
__________________
Here...let me improve it for you!

*Puff of smoke* ....oops...
raitl is offline  
Old 10th February 2006, 03:36 PM   (permalink)
Default

You need to clear the TMR0IF flag before you exit the ISR.You dont seem to be doing so.
sandeepa is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:34 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker