What I trying. Omit PBP code from ASM interrupt routine.
But this try not work, of course.
Where is the problem?
Code:#CONFIG __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF #ENDCONFIG DEFINE INTHAND INT DEFINE NO_CLRWDT 1 DEFINE OSC 4 OSCCON = %01101010 TRISA = %011000 ; RA4 input for battery measurement, RA3 input on change, rest output ANSELA = %0000 ; ADC Disable OPTION_REG = %10000111 ; Disable internal pull-ups, TMR0 On, prescaller to 256 FVRCON = %10011000 ; Internal reference to 2048mV CM1CON0 = %10100110 ; Comparator output to C1OUT, switch on LED if voltage is below ref. 2,048V CM1CON1 = %00100001 ; C1IN1- pin is RA4, comparator voltage input, C1IN1+ positive input to FVR set to 2,048V LATA = %000001 ; init state of pin RA0 and RA1, LEDs connected to these pins T1CON = %00110001 ; TMR1 On, prescaller 1:8, Fosc/4 INTCON = %11001000 ; Enable GIE, PEIE, IOCIE PIE1.0 = 1 ; Enable TMR1IE Owerflow interrupt IOCAN.3 = 1 ; Enable RA3 negative edge OnChange interrupt Switch var bit SYSTEM : switch = 0 ; ------------ With TMR1 and interrupt, oscilator 4MHz --------------- Main: if porta.3=0 and switch=1 then LATA = LATA ^ %100000 pressed: pause 20 if porta.3=0 then pressed ; if the button is still pressed loop and wait for release Switch=0 endif goto main asm INT banksel IOCAF btfsc IOCAF,3 bsf Switch ; set bit in Switch to 1 bcf IOCAF,3 RETFIE endasm




Bookmarks