Hi all, I've almost completed a program for a pic12f675 to monitor series connected lithium batteries and enable outputA when they are within set levels and also enable outputB using an IOC interrupt when an input hi triggers the service to run then disable outputB when input is released then return to normal routine.
Basically when the outputb is enabled during interrupt it clears the input pin state causing the loop polling of the input to fail and exit from interrupt prematurely. Asm file is attached but here is the basic lines the i'm having problems with. Thanks in advance for any help.
Start
org 0x0000 ;program starts at location 000
goto Setup
org 0x0004
nop
bsf GPIO,2
call del_0
btfsc GPIO,3
goto $-2
bcf GPIO,2
bcf INTCON,0
retfie
SetUp
bsf STATUS,5 ;bank 1
movlw b'00010011'
movwf ANSEL ;
movlw b'11100000' ;,
movwf OPTION_REG
bcf STATUS,5 ;bank 0
movlw 07h
movwf CMCON ;
bsf INTCON,3 ;IOC interrupt enable
clrf ADCON0
Clrf PIR1 ;CLEAR ADC interrupt FLAG BIT
bsf STATUS,5 ;Bank 1
clrf VRCON
movlw b'00001000'
movwf IOC ;SET ADC INTERRUPT
clrf PIE1 ;SET ADC INTERRUPT
movlw b'00001011' ; Set GPIO INPUTS
movwf TRISIO
;calibrating the internal oscillator
call 0x3ff ;get the calibration value
movwf OSCCAL ;calibrate oscillator
bcf STATUS,5 ;bank 0
clrf GPIO ;Clear GPIO
call cutselect
goto Main
Basically when the outputb is enabled during interrupt it clears the input pin state causing the loop polling of the input to fail and exit from interrupt prematurely. Asm file is attached but here is the basic lines the i'm having problems with. Thanks in advance for any help.
Start
org 0x0000 ;program starts at location 000
goto Setup
org 0x0004
nop
bsf GPIO,2
call del_0
btfsc GPIO,3
goto $-2
bcf GPIO,2
bcf INTCON,0
retfie
SetUp
bsf STATUS,5 ;bank 1
movlw b'00010011'
movwf ANSEL ;
movlw b'11100000' ;,
movwf OPTION_REG
bcf STATUS,5 ;bank 0
movlw 07h
movwf CMCON ;
bsf INTCON,3 ;IOC interrupt enable
clrf ADCON0
Clrf PIR1 ;CLEAR ADC interrupt FLAG BIT
bsf STATUS,5 ;Bank 1
clrf VRCON
movlw b'00001000'
movwf IOC ;SET ADC INTERRUPT
clrf PIE1 ;SET ADC INTERRUPT
movlw b'00001011' ; Set GPIO INPUTS
movwf TRISIO
;calibrating the internal oscillator
call 0x3ff ;get the calibration value
movwf OSCCAL ;calibrate oscillator
bcf STATUS,5 ;bank 0
clrf GPIO ;Clear GPIO
call cutselect
goto Main