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.

code debugging

Status
Not open for further replies.

raitl

New Member
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top