--Apple-Mail-4-559188363 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, I'm having a little problem with controlling Timer 0 and Timer 1 interrupts separately, on a PIC12F675. With Timer 1 disabled I'm able to control Timer 0 effectively with the INTCON,T0IE bit. Off and on. But when I enable Timer 1, Timer 0 also starts up and starts interrupting the processor. Is this normal? Is it a known problem? Or am I missing something? While it's not a big deal, it can be handled in the isr. But it's a headache to trouble shoot and quite disconcerting when you expect only one timer to be in operation, and another that should be off, is generating interrupts. I'd like TMR1 to be on, and not have TMR0 interrupting thr processor These are my settings ; initialize interrupts banksel INTCON ; Bank 0 movlw b'10100000' ; 1------- (GIE)1=interrupts enabled ; -0------ (PEIE)1=enable peripheral interrupts ; --1----- (T0IE)0=disable TMR0 overflow interrupt <- controls TMR0 effectively ; ---0---- (INTE)0=disable GP2/INT external interrupt ; ----0--- (GPIE)0=disable GPIO port change interrupt ; -----0-- (T0IF)0=no on TMR0 overflow ; ------0- (INTF)0=no GP2/INT external interrupt ; -------0 (GPIF)0=no GPIO port change movwf INTCON but when ; enable peripheral interrupts banksel PIE1 ; Bank 1 movlw b'00000001' ; 0------- 0=disable EE write complete interrupt ; -0------ 0=disable A/D converter interrupt ; --xx---- not implemented ; ----0--- 0=comparator interrupt disabled ; -----xx- not implemented ; -------1 (TMR1IE)1=enable TMR1 overflow interrupt ; strangely this seems to also turns on timer 0 movwf PIE1 ; initialize TMR1 banksel T1CON ; Bank 0 movlw b'00000101' ; x------- not implemented ; -0------ 0=gate disabled ; --00---- 11=1:8 prescaler, ; 10 = 1:4,01 = 1:2,00 = 1:1 ; ----0--- (T1OSCEN)0=LP oscillator is off ; -----1-- (T1SYNC) 1=external clock input not synchronized ; ------0- (TMR1CS) 0=internal clock ; -------1 (TMR1ON) 1=timer1 enabled movwf T1CON ; initialize interrupts banksel INTCON ; Bank 0 movlw b'01000000' ; 0------- (GIE)1=interrupts enabled ; -1------ (PEIE)1=enable peripheral interrupts ; --0----- (T0IE)0=disable TMR0 overflow interrupt <-- TMR0 runs irespective of this ; ---0---- (INTE)0=disable GP2/INT external interrupt bit setting ; ----0--- (GPIE)0=disable GPIO port change interrupt ; -----0-- (T0IF)0=no on TMR0 overflow ; ------0- (INTF)0=no GP2/INT external interrupt ; -------0 (GPIF)0=no GPIO port change movwf INTCON ; ; Clear TMR0, its Flag and enable interrupts ; clrf TMR0 ; start timer known state ; bcf INTCON,T0IF ; clear TMR0 interrupt flag bsf INTCON,GIE ; enable global interrupts complete code attached. T0IE becomes effective again if any of the TMR1 control bits are cleared to stopping TMR1. I have some PIC12F683s coming so I can see if I have the same trouble with them. Thanks, Heinz Czychun --Apple-Mail-4-559188363 Content-Transfer-Encoding: quoted-printable Content-Type: application/octet-stream; x-unix-mode=0644; name=BresClk_T1-iNT.ASM Content-Disposition: attachment; filename=BresClk_T1-iNT.ASM ;**********************************************************************=0D= =0A;=20=20=20This=20Program=20uses=20Timer0=20to=20set=20both=20the=20hi=20= and=20low=20period=20of=20a=20=20=20*=0D=0A;=20=20=20square=20wave=20of=20= fixed=20frequency.=20Thus=20adjusting=20the=20duty=20cycle.=20=20=20=20*=0D= =0A;=20=20=20The=20duty=20cycle=20is=20based=20on=20the=20ADC=20value=20= which=20is=20checked=20during=20=20*=0D=0A;=20=20=20the=20longer=20of=20= the=20two=20periods.=20The=20varying=20voltage=20is=20displayed=20=20=20= *=0D=0A;=20=20=20as=20a=20differing=20brightness=20level=20of=20the=20= DS1=20LED=20of=20the=20LPC=20Board.=20=20*=20=20=0D=0A;=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A= ;**********************************************************************=0D= =0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20= =20=20=20Filename:=09=20=20=20=20675-ADC_sPWM.asm=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20*=0D=0A;=20=20=20=20Date:=20=20=20=20=20=20=20=20=20=20May=2028,=20= 2009=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20=20=20=20File=20= Version:=20=20Dev=201.0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20*=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D= =0A;=20=20=20=20Author:=20=20=20=20=20=20=20=20Heinz=20Czychun=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20*=0D=0A;=20=20=20=20Company:=20=20=20=20=20=20=20= N/A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D= =0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A= ;**********************************************************************=0D= =0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20= =20=20=20Files=20required:=20p12f675.inc=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20*=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= 12F675.lkr=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A= ;**********************************************************************=0D= =0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20= =20=20=20Notes:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20*=0D=0A;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20*=0D=0A= ;**********************************************************************=0D= =0A=0D=0A=09list=20=20=20=20=20=20p=3D12f675=20=20=20=20=20=20=20=20=20=20= =20=20;=20list=20directive=20to=20define=20processor=0D=0A=09#include=20= =20=20=20=20=20=20=20=20;=20processor=20specific=20variable=20= definitions=0D=0A=0D=0A=09errorlevel=20=20-302=20=20=20=20=20=20=20=20=20= =20=20=20=20=20;=20suppress=20message=20302=20from=20list=20file=0D=0A=0D= =0A=09__CONFIG=20=20=20_CP_OFF=20&=20_CPD_OFF=20&=20_BODEN_OFF=20&=20= _MCLRE_ON=20&=20_WDT_OFF=20&=20_PWRTE_ON=20&=20_INTRC_OSC_NOCLKOUT=20=20=0D= =0A=0D=0A;=20'__CONFIG'=20directive=20is=20used=20to=20embed=20= configuration=20word=20within=20.asm=20file.=0D=0A;=20The=20lables=20= following=20the=20directive=20are=20located=20in=20the=20respective=20= .inc=20file.=0D=0A;=20See=20data=20sheet=20for=20additional=20= information=20on=20configuration=20word=20settings.=0D=0A;=0D=0A;=0D=0A;=20= Config=20Register=0D=0A;=0D=0A;Bits=2013-12=20-=20BandGap=20calibration=20= -=2000=20Lowest=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20-=2011=20Highest=0D=0A= ;Bits=2011-=209=20-=20Don't=20Care=0D=0A;=0D=0A;Bit=20=20=20=20=20=208=20= -=20~CPD:=20Data=20Code=20Protection=20=20=20=20=20-=201=20no=20code=20= protect=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= -=200=20code=20protect=0D=0A;Bit=20=20=20=20=20=207=20-=20~CP:=20=20= Program=20=20Code=20Protection=20-=201=20no=20code=20protect=0D=0A;=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20-=200=20code=20= protect=0D=0A;Bit=20=20=20=20=20=206=20-=20BODEN:=20Brown-out=20Detect=20= =20=20=20=20=20=20=20-=201=20BOD=20on=0D=0A;=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20-=200=20BOD=20off=0D=0A;Bit=20=20=20=20=20=20= 5=20-=20MCLRE:=20GP3/MCLR=20pin=20function=20=20=20-=201=20~MCLRE=20=0D=0A= ;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20-=200=20no=20= ~MCLRE=0D=0A;Bit=20=20=20=20=20=204=20-=20PWRTE:=20Power-up=20Timer=20=20= =20=20=20=20=20=20=20=20-=201=20no=20Timer=0D=0A;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20-=200=20yes=20Timer=0D=0A;Bit=20=20=20=20= =20=203=20-=20WDTE:=20Watchdog=20Timer=20=20=20=20=20=20=20=20=20=20=20-=20= 1=20yes=20Timer=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20-=200=20no=20Timer=0D=0A;Bits=202=20-=200=20-=20FOSC2:FOSC0:=20= Oscillator=20=20=20=20=20=20=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20-=20= 111=20RC=20oscillator:=20CLKOUT=20-=20GP4,=20RC=20-=20GP5=0D=0A;=20=20=20= =20=20=20=20=20=20=20=20-=20110=20RC=20oscillator:=20I/O=20function=20-=20= GP4,=20Rc=20-=20GP5=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20-=20101=20= INTOSC=20oscillator:=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20CLKOUT=20function=20-=20GP4,=20I/O=20function=20-=20GP5=20=0D=0A;=20= =20=20=20=20=20=20=20=20=20=20-=20100=20INTOSC=20oscillator:=20=0D=0A;=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20I/O=20function=20-=20= GP4,=20I/O=20function=20-=20GP5=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20= -=20011=20EC:=20I/O=20function=20-=20GP4,=20CLKIN=20-=20GP5=20=0D=0A;=20=20= =20=20=20=20=20=20=20=20=20-=20010=20HS=20oscillator:=20=0D=0A;=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20High=20speed=20crystal/resonator-=20= GP4=20&=20GP5=0D=0A;=20=20=20=20=20=20=20=20=20=20=20-=20001=20XT=20= oscillator:=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= Crystal/resonator=20-=20GP4=20&=20GP5=0D=0A;=20=20=20=20=20=20=20=20=20=20= =20-=20000=20LP=20oscillator:=20=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20Low=20power=20crystal=20on=20GP4=20&=20GP5=0D=0A;=0D=0A;=20= CONFIG=20=97=20CONFIGURATION=20WORD=20(ADDRESS:=202007h)=20=0D=0A;=20= CONFIG=20Setting=20-=200x01FF=0D=0A;=0D=0A;=20Configured=20for=20Code=20= Protect=20=20=20=20=20=20=20=20off=0D=0A;=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20Data=20EEPROM=20Protect=20off=0D=0A;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20Brownout=20Detect=20=20=20=20=20off=0D=0A;=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20Master=20Clear=20=20=20=20=20=20=20= =20on=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20Watchdog=20= Timer=20=20=20=20=20=20off=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20Power-up=20Timer=20=20=20=20=20=20on=0D=0A;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20Internal=20Oscillator=20on=20with=20I/O=20on=20= GP4=20&=20GP5=0D=0A;=0D=0A;=20This=20will=20setup=20the=20F675=20to=20= loose=20only=20three=20pins=0D=0A;=20Vdd=20=20-=20Pin=201=0D=0A;=20Vss=20= =20-=20Pin=208=0D=0A;=20MClr=20-=20Pin=204=20(J1-2)=0D=0A;=20=20=20=20=20= =20=20=20=20=20=20=20=20=20___________=0D=0A;=20=20=20=20=20=20=20=20=20= Vdd=20-|=201=20=20=20=20=208=20|-=20=20Vss=0D=0A;=20=20=20GP5=20T1CKI=20= -|=20=20=20=20=20=20=20=20=20|-=20=20GP0=20AN0=20CIN+=0D=0A;=20GP4=20AN3=20= T1G=20-|=20=20=20=20=20=20=20=20=20|-=20=20GP1=20AN1=20CIN=20VREF=0D=0A;=20= =20=20=20=20=20=20=20MClr=20-|=204=20=20=20=20=205=20|-=20=20GP2=20AN2=20= T0CKI=20INT=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20-----------=0D= =0A;=0D=0A;=20Available=20Pins=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20LPC=20J1=20Connector=20=20=20=20=0D=0A;=0D=0A;=20GP0=20(RA0)=20= -=20Pin=207=20-=20AN0/CIN+=20=20=20=20=20=20=20=20=20J1=20-=20=207=0D=0A= ;=20GP1=20(RA1)=20-=20Pin=206=20-=20AN1/CIN-/VREF=20=20=20=20J1=20-=20=20= 8=0D=0A;=20GP2=20(RA2)=20-=20Pin=205=20-=20AN2/T0CKI/INT=20=20=20=20J1=20= -=20=209=0D=0A;=20GP4=20(RA4)=20-=20Pin=203=20-=20AN3/T1G=20=20=20=20=20=20= =20=20=20=20J1=20-=20=202=0D=0A;=20GP5=20(RA5)=20-=20Pin=202=20-=20T1CKI=20= =20=20=20=20=20=20=20=20=20=20=20J1=20-=20=201=0D=0A;=0D=0A;=20LPC=20= Board=20Resources=20=20=20=20=20=20=20=20=20=20=20=20=20=20LPC=20J1=20= Connector=0D=0A;=20Button=20-=20SW1=20(RA3)=20-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20J1=20-=20=202=0D=0A;=0D=0A;=20LED=20=20=20=20-=20= DS1=20(RC0)=20-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20J1=20-=20= 10=0D=0A;=20LED=20=20=20=20-=20DS1=20(RC1)=20-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20J1=20-=2011=0D=0A;=20LED=20=20=20=20-=20DS1=20= (RC2)=20-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20J1=20-=2012=0D= =0A;=20LED=20=20=20=20-=20DS1=20(RC3)=20-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20J1=20-=20=206=0D=0A;=0D=0A;=20Pot=20=20=20=20-=20RP1=20= (RA0)=20-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20J1=20-=20=20= 7=0D=0A;=0D=0A;=20Hardware=20considerations:=0D=0A;=20On=20the=20LPC=20= Board=20the=20LEDs=20are=20not=20connected=20to=20the=20pins=20= associated=0D=0A;=20with=20the=208-pin=20PICs=20so=20the=20DS1=20LED=20= must=20be=20jumpered=20to=20GP1=20(pin=206)=0D=0A;=20on=20the=2012F675.=20= This=20is=20done=20at=20connector=20J1=20by=20connecting=20a=20jumper=20=0D= =0A;=20wire=20between=20J1-8=20(GP1)=20and=20J1-10=20(RC0=20-=20DS1).=20= Alternatively=20an=20LED=0D=0A;=20with=20a=20series=20resistor=20can=20= be=20connected=20to=20J1-8.=20Connect=20this=20just=20=0D=0A;=20like=20= the=20on-board=20LEDs.=0D=0A;=0D=0A;*****=20VARIABLE=20DEFINITIONS=0D=0A= #define=20=20=20=20=20LED_DS1=201=20=20=20;=20LED=20connected=20to=20GP1=0D= =0A;=0D=0A;*******=20Macro=20definitions=20= **********************************=0D=0A;=0D=0AMOVLF=20=20=20macro=20=20=20= literal,=20dest=0D=0A=20=20=20=20=20=20=20=20movlw=20=20=20literal=0D=0A=20= =20=20=20=20=20=20=20movwf=20=20=20dest=0D=0A=20=20=20=20=20=20=20=20= endm=0D=0A;=0D=0A= ;**********************************************************************=0D= =0A;=20example=20of=20using=20Shared=20Uninitialized=20Data=20Section=0D=0A= INT_VAR=09=09UDATA_SHR=090x20=20=20=20=0D=0Aw_temp=09=09RES=20=20=20=20=20= 1=09;=20variable=20used=20for=20context=20saving=20=0D=0Astatus_temp=09= RES=20=20=20=20=201=09;=20variable=20used=20for=20context=20saving=0D=0A= ;=0D=0AsGPIO=20=20=20=20=20=20=20RES=20=20=20=20=201=20=20=20;=20Shadow=20= Register=20for=20output=20to=20prevent=0D=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20RMW=20errors=0D=0AXorMask=20= =20=20=20=20RES=20=20=20=20=201=20=20=20;=20Reg=20to=20hold=20LED=20Mask=20= bit=0D=0A;=0D=0Arlovrflag=20=20=20RES=20=20=20=20=201=20=20=20;=20flag=20= to=20signal=20main=20loop=20to=201=20sec=20has=20passed=0D=0A;=0D=0A= bres_hi=09=09RES=20=20=20=20=201=09;=20hi=20byte=20of=20our=2024bit=20= variable=0D=0Abres_mid=09RES=20=20=20=20=201=09;=20mid=20byte=0D=0A= bres_lo=09=09RES=20=20=20=20=201=09;=20lo=20byte=0D=0ATemp_mid=20=20=20=20= RES=20=20=20=20=201=20=20=20;=20Temperary=20reg=20to=20hold=20the=20= bres_mid=20value=0D=0A;=0D=0A= ;**********************************************************************=0D= =0ARESET_VECTOR=09CODE=090x000=09;=20processor=20reset=20vector=0D=0A=20=20= =20=20goto=20=20=20=20main=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;=20go=20to=20beginning=20of=20program=0D=0A=0D=0AINT_VECTOR=09=20=20=20=20= CODE=20=20=20=200x004=20=20=20;=20interrupt=20vector=20location=0D=0A=20=20= =20=20goto=20=20=20=20iServ=0D=0A;=0D=0Amain=0D=0A;=20Start=20PIC_Setup=0D= =0A;=0D=0A;=20these=20first=204=20instructions=20are=20not=20required=20= if=20the=20internal=20oscillator=20is=20not=20used=0D=0A;=0D=0A=20=20=20=20= =20=20=20=20call=20=20=20=200x3FF=20=20=20=20=20=20=20=20=20=20=20=20;=20= retrieve=20factory=20calibration=20value=0D=0A=20=20=20=20=20=20=20=20= banksel=20OSCCAL=20=20=20=20=20=20=20=20=20=20=20;=20select=20register=20= bank=20that=20contains=20=0D=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20OSCCAL=20= (Bank=201)=20=0D=0A=20=20=20=20=20=20=20=20movwf=20=20=20OSCCAL=20=20=20=20= =20=20=20=20=20=20=20;=20update=20register=20with=20factory=20cal=20= value=20=0D=0A=0D=0A;=20***=20Control=20Register=20Initialization=20= ***********=0D=0A;=0D=0A;=20set=20up=20direction=20of=20I/O=20pins=0D=0A=20= =20=20=20=20=20=20=20banksel=20TRISIO=20=20=20=20=20=20;=20Bank=201=0D=0A= =20=20=20=20=20=20=20=20movlw=20=20=20b'00000001'=20=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20xx------=20=20not=20implemented=0D=0A= =20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20--0-----=20=20= 0=3Doutput,=20GP5,=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20= =20=20---0----=20=200=3Doutput,=20GP4,=20=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20----x---=20=20not=20used,=20GP3,=20In=20this=20= case=20used=20by=20MCLR=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20= =20=20-----0--=20=200=3Doutput,=20GP2,=20=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20------0-=20=200=3Doutput,=20GP1,=20=0D=0A=20=20=20= =20=20=20=20=20;=20=20=20=20=20=20=20=20=20-------1=20=201=3Dinput=20for=20= analog=20input=0D=0A=20=20=20=20=20=20=20=20;=0D=0A=20=20=20=20=20=20=20=20= movwf=20=20=20TRISIO=0D=0A;=0D=0A;=20set=20up=20Option=20Register=0D=0A=20= =20=20=20=20=20=20=20clrwdt=09=09=20=20=20=20;clear=20WDT=20prep=20= prescale=20assign=0D=0A=20=20=20=20=20=20=20=20banksel=20=20OPTION_REG=20= ;=20Bank=201=0D=0A=20=20=20=20=20=20=20=20movlw=20=20=20b'00001000'=20=20= =20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=200-------=20=20= 1=3Ddisabled,=20no=20GPIO=20Pull-ups=20=20=20=20=20GPPU:=20GPIO=20= Pull-ups=20=20=20=20=20=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20-0------=20=200=3Dfalling=20edge=20interrupt,=20=20=20=20=20=20= INTEDG:=20Interrupt=20Edge=20of=20GP2=0D=0A=20=20=20=20=20=20=20=20;=20=20= =20=20=20=20=20=20=20--0-----=20=200=3DInternal=20inst=20clock=20= (CLKOUT),=20=20T0CS:=20TMR0=20Clock=20Source=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20---0----=20=200=3DInc=20on=20lo^hi=20= transition=20on=20GP2,T0SE:=20TMR0=20Source=20Edge=0D=0A=20=20=20=20=20=20= =20=20;=20=20=20=20=20=20=20=20=20----1---=20=201=3DPrescaler=20assigned=20= to=20WDT,=20=20=20=20=20PSA:=20Prescaler=20Assignment=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20-----0--=20=20001=20Prescaler=20= 1:4,=20=20=20=20=20=20=20=20=20=20=20=20PS2-PS0:=20Prescaler=20Rate=0D=0A= =20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20------0-=20=20Bits=20= =20TMR0=20=20=20=20WDT=20=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20= =20=20=20=20-------0=20=20000=20=20=20=201:2=20=20=20=201:1=0D=0A=20=20=20= =20=20=20=20=20;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= 001=20=20=20=201:4=20=20=20=201:2=0D=0A=20=20=20=20=20=20=20=20;=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20010=20=20=20=201:8=20=20=20= =201:4=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20011=20=20=20=201:16=20=20=201:8=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20100=20= =20=20=201:32=20=20=201:16=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20101=20=20=20=201:64=20=20=201:32=0D= =0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20110=20=20=20=201:128=20=201:64=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20111=20=20=20=20= 1:256=20=201:128=0D=0A=20=20=20=20=20=20=20=20;=0D=0A=20=20=20=20=20=20=20= =20movwf=20=20=20=20OPTION_REG=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0D= =0A;=0D=0A;=20set=20up=20comparator=0D=0A=20=20=20=20=20=20=20=20banksel=20= CMCON=20=20=20=20=20=20=20;=20Bank=200=0D=0A=20=20=20=20=20=20=20=20= movlw=20=20=20b'00000111'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20x-------=20=20not=20implemented=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20-0------=20=20output=20bit=0D=0A=20=20=20=20=20=20= =20=20;=20=20=20=20=20=20=20=20=20--x-----=20=20not=20implemented=0D=0A=20= =20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20---0----=20=20= 0=3Dnon-inverted=20output=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20----0---=20=200=3DVin-=20to=20Cin-=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20-----111=20=20111=3Dcomparator=20off=0D=0A=20= =20=20=20=20=20=20=20movwf=20=20=20CMCON=0D=0A;=0D=0A;=20set=20up=20A/D=20= converter=0D=0A=20=20=20=20=20=20=20=20banksel=20ANSEL=20=20=20=20=20=20=20= ;=20Bank=201=0D=0A=20=20=20=20=20=20=20=20movlw=20=20=20b'00010000'=0D=0A= =20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20x-------=20=20not=20= implemented=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= -001----=20=20001=3DFocs/8=20Conversion=20Clock=0D=0A=20=20=20=20=20=20=20= =20;=20=20=20=20=20=20=20=20=20----0---=20=200=3Ddigital=20I/O,=20GP4,=20= not=20used=20by=20ADC=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20= =20=20-----0--=20=200=3Ddigital=20I/O,=20GP2,=20not=20used=20by=20ADC=0D=0A= =20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20------0-=20=20= 0=3Ddigital=20I/O,=20GP1,=20not=20used=20by=20ADC=0D=0A=20=20=20=20=20=20= =20=20;=20=20=20=20=20=20=20=20=20-------0=20=201=3Danalog=20=20I/O,=20= GP0,=20analog=20input=0D=0A=20=20=20=20=20=20=20=20movwf=20=20=20ANSEL=0D= =0A;=20=20=20=20=20=20=20=20=0D=0A=20=20=20=20=20=20=20=20banksel=20= ADCON0=20=20=20=20=20=20;=20Bank=200=0D=0A=20=20=20=20=20=20=20=20movlw=20= =20=20b'00000000'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= 0-------=20=200=3Dleft=20justified=20result=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20-0------=20=200=3DVdd=20is=20voltage=20= reference=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= --xx----=20=20not=20implemented=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20= =20=20=20=20=20----00--=20=2000=3Dselect=20channel=200=20(GP0)=0D=0A=20=20= =20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20------0-=20=200=3DA/D=20= conversion=20not=20started=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20-------0=20=200=3DA/D=20converter=20module=20is=20in=20= operation=0D=0A=20=20=20=20=20=20=20=20movwf=20=20=20ADCON0=0D=0A;=0D=0A= ;=20initialize=20output=20pins=0D=0A=20=20=20=20=20=20=20=20banksel=20= GPIO=20=20=20=20=20=20=20=20;=20Bank=200=0D=0A=20=20=20=20=20=20=20=20= movlw=20=20=20b'00000000'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20xx------=20=20not=20implemented=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20--0-----=20=200=3Doutput=20low,=20GP5,=20=20=20=20= =0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20---0----=20=20= 0=3Doutput=20low,=20GP4,=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20= =20=20=20=20----x---=20=200=3Doutput,=20GP3,=20In=20this=20case=20used=20= by=20MCLR=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= -----0--=20=200=3Doutput=20low,=20GP2,=20=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20------0-=20=200=3Doutput=20low,=20GP1,=20=0D=0A=20= =20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20-------0=20=200=3Doutput=20= doesn't=20matter=20as=20GP0,=20is=20an=20input=0D=0A=20=20=20=20=20=20=20= =20movwf=20=20=20GPIO=0D=0A;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=0D=0A;=20initialize=20interrupts=0D=0A;=20=20=20=20=20=20=20banksel=20= INTCON=20=20=20=20=20=20;=20Both=20Banks=0D=0A=20=20=20=20=20=20=20=20= movlw=20=20=20b'11000000'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=201-------=20=201=3Dinterrupts=20enabled=0D=0A=20=20=20=20=20=20=20= =20;=20=20=20=20=20=20=20=20=20-1------=20=201=3Denable=20peripheral=20= interrupts=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= --0-----=20=200=3Ddisable=20TMR0=20overflow=20interrupt=0D=0A=20=20=20=20= =20=20=20=20;=20=20=20=20=20=20=20=20=20---0----=20=200=3Ddisable=20= GP2/INT=20external=20interrupt=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20= =20=20=20=20=20----0---=20=200=3Ddisable=20GPIO=20port=20change=20= interrupt=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= -----0--=20=200=3Dno=20on=20TMR0=20overflow=20(TM0IF)=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20------0-=20=200=3Dno=20GP2/INT=20= external=20interrupt=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20= =20-------0=20=200=3Dno=20GPIO=20port=20change=0D=0A=20=20=20=20=20=20=20= =20movwf=20=20=20INTCON=0D=0A;=20=20=20=20=0D=0A=20=20=20=20=20=20=20=20= banksel=20PIE1=20=20=20=20=20=20=20=20;=20Bank=201=0D=0A=20=20=20=20=20=20= =20=20movlw=20=20=20b'00000001'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20= =20=20=20=20=200-------=20=200=3Ddisable=20EE=20write=20complete=20= interrupt=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= -0------=20=200=3Ddisable=20A/D=20converter=20interrupt=0D=0A=20=20=20=20= =20=20=20=20;=20=20=20=20=20=20=20=20=20--xx----=20=20not=20implemented=0D= =0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20----0---=20=20= 0=3Dcomparator=20interrupt=20disabled=0D=0A=20=20=20=20=20=20=20=20;=20=20= =20=20=20=20=20=20=20-----xx-=20=20not=20implemented=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20-------1=20=200=3Denable=20TMR1=20= overflow=20interrupt=0D=0A=20=20=20=20=20=20=20=20movwf=20=20=20PIE1=0D=0A= ;=20=20=20=20=20=20=20=20=0D=0A=20=20=20=20=20=20=20=20banksel=20PIR1=20=20= =20=20=20=20=20;=20Bank=200=0D=0A=20=20=20=20=20=20=20=20movlw=20=20=20= b'01000000'=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= 0-------=200=3Dno=20EE=20write=20complete=0D=0A=20=20=20=20=20=20=20=20;=20= =20=20=20=20=20=20=20=20-1------=201=3Dyes=20A/D=20conversion=20complete=0D= =0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20--xx----=20not=20= implemented=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= ----0---=200=3Dno=20comparator=20interrupt=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20-----xx-=20not=20implemented=0D=0A=20=20=20=20= =20=20=20=20;=20=20=20=20=20=20=20=20=20-------0=200=3Dno=20TMR1=20= overflow=20()TMR1F=0D=0A=20=20=20=20=20=20=20=20movwf=20=20=20PIR1=0D=0A= ;=0D=0A;=20initialize=20TMR1=0D=0A=20=20=20=20=20=20=20=20banksel=20= T1CON=20=20=20=20=20=20=20;=20Bank=200=0D=0A=20=20=20=20=20=20=20=20= movlw=20=20=20b'00000001'=20=20=20=20=0D=0A=20=20=20=20=20=20=20=20;=20=20= =20=20=20=20=20=20=20x-------=20=20not=20implemented=0D=0A=20=20=20=20=20= =20=20=20;=20=20=20=20=20=20=20=20=20-0------=20=200=3Dgate=20disabled=0D= =0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20--00----=20=20= 11=3D1:8=20prescaler,=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=2010=20=3D=201:4,01=20=3D=201:2,00=20= =3D=201:1=20=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20=20= ----0---=20=200=3DLP=20oscillator=20is=20off=0D=0A=20=20=20=20=20=20=20=20= ;=20=20=20=20=20=20=20=20=20-----0--=20=201=3Dexternal=20clock=20input=20= not=20synchronized=0D=0A=20=20=20=20=20=20=20=20;=20=20=20=20=20=20=20=20= =20------0-=20=200=3Dinternal=20clock=0D=0A=20=20=20=20=20=20=20=20;=20=20= =20=20=20=20=20=20=20-------1=20=201=3Dtimer=20enabled=0D=0A=20=20=20=20=20= =20=20=20movwf=20=20=20T1CON=0D=0A;=0D=0A;=20PIC=20Register=20Setup=20= complete=0D=0A= ;_________________________________________________________________________= _________=0D=0A;=0D=0A=20=20=20=20bsf=20=20XorMask,=20LED_DS1=0D=0A=20=20= =20=20bsf=20=20GPIO,=20LED_DS1=20=20=20=20;=20start=20with=20LED-DS1=20= off=0D=0A;=0D=0A;=20Setup=20for=20TMR0=20and=20enable=20interrupts=0D=0A= ;=0D=0A;=20=20=20=20clrf=20=20=20=20TMR0=20=20=20=20=20=20=20=20;=20= start=20timer=20known=20state=0D=0A;=0D=0A=20=20=20=20bcf=09=20= INTCON,T0IF=20;=20clear=20TMR0=20interrupt=20flag=0D=0A;=0D=0AMainLoop:=0D= =0A=0D=0A=20=20=20=20goto=20=20=20=20MainLoop=20=20=20=20;=20go=20back=20= and=20get=20a=20knew=20ADC=20value=0D=0A;=0D=0A;=20End=20of=20Main=0D=0A= ;_________________________________________________________________________= _________=0D=0A;=0D=0A;=20Control=20is=20here=20because=20Timer0=20has=20= rolled=20over=0D=0A;=0D=0AiServ=0D=0A=20=20=20=20movwf=20=20=20w_temp=20=20= =20=20=20=20=20=20=20=20;=20save=20off=20current=20W=20register=20= contents=0D=0A=20=20=20=20movf=20=20=20=20STATUS,w=20=20=20=20=20=20=20=20= ;=20move=20status=20register=20into=20W=20register=0D=0A=20=20=20=20= movwf=20=20=20status_temp=20=20=20=20=20;=20save=20off=20contents=20of=20= STATUS=20register=0D=0A;=0D=0A=20=20=20=20=20=20bcf=20=20=20INTCON,GIE=0D= =0A;=0D=0A=20=20=20=20=20btfsc=20=20INTCON,T0IF=0D=0A=20=20=20=20=20=20= goto=20=20ServiceTimer0=0D=0A=20=20=20=20=20btfsc=20=20PIR1,T1IF=20=20=20= =20=20=0D=0A=20=20=20=20=20=20goto=20=20ServiceTimer1=0D=0A=0D=0A=20=20=20= =20=20=20goto=20=20iServ_Exit=0D=0A;=0D=0AServiceTimer1=0D=0A=20=20=20= banksel=20=20PIR1=0D=0A=09=20=20=20bcf=20=20PIR1,T1IF=09=09;=20clear=20= TMR1=20interrupt=20flag=0D=0A;=0D=0A;=20=20=20=20=20movlw=20'>'=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=0D=0A;=09=20movwf=20serdata=20=20=20=20= =20=20=20=20=20=20=20=20=20=0D=0A;=09=20=20call=20serxmt=0D=0A;=0D=0A=09= ;-------------------------------------------------=0D=0A=09;=20Note!=20= we=20get=20here=20every=2065,536=20instructions,=20we=0D=0A=09;=20can=20= now=20do=20our=20special=20one=20second=20timing=20system.=09=09=09=09=0D= =0A=0D=0A=09;=20This=20consists=20of=20three=20main=20steps;=0D=0A=09;=20= *=20subtract=2065,536=20counts=20from=20our=2024bit=20variable=0D=0A=09;=20= *=20test=20if=20we=20reached=20the=20setpoint=20(high=20byte=20=3D=200)=0D= =0A=09;=20*=20if=20so,=20add=201,000,000=20counts=20to=2024bit=20= variable=20and=20generate=20event.=0D=0A=20=20=20=20;=20*=20assuming=20= an=204MHz=20clock,=20and=20TMR1=20no=20prescaler,=20ticks=20every=204=20= Osc=20clocks=0D=0A=20=20=20=20;=20*=201MHz=20operation=0D=0A=09= ;-------------------------------------------------=0D=0A=20=20banksel=20=20= bres_hi=0D=0A=20=20=20decfsz=20=20bres_hi,f=20=20=20=20=20=20=20=20=20=20= ;=20decrement=20bresenham=20counter=20high=20byte=0D=0A=20=20=20=20=20= goto=20=20iServ_Exit=20=20=20=20=20=20=20=20=20;=20lf=20non-zero=20exit=20= isr=0D=0A=0D=0A;=20since=20bres_hi=20is=200=0D=0A;=20so=20a=20sec=20= elapsed,=20more=20or=20less=0D=0A;=20add=201M=20(0F=2042=2040=20in=20= hex)to=20bresenham=20accumulator=0D=0A;=0D=0A=20=20=20=20MOVLF=20=200F,=20= bres_hi=20=20=20=20=20=20=20=20;=20move=20hign=20value=20into=20= bres-accu=0D=0A=20=20=20=20MOVLF=20=2042,=20Temp_mid=20=20=20=20=20=20=20= ;=20need=20to=20hold=20mid=20count=20in=20a=20temp=20register=0D=0A;=20= do=20the=20addition=0D=0A=20=20=20=20=20=20bcf=20=20STATUS,=20C=20=20=20=20= =20=20=20=20=20=20;=20clear=20carry=20flag=0D=0A=20=20=20=20movlw=20=20= 0x40=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20get=20low=20value=0D= =0A=20=20=20=20addwf=20=20bres_lo,=20f=20=20=20=20=20=20=20=20=20;=20add=20= low=20count=20to=20bres-accu=20low=0D=0A=20=20=20=20skpnc=0D=0A=20=20=20=20= incf=20=20=20Temp_mid,=20f=20=20=20=20=20=20=20=20;=20if=20overflow=20= add=201=20to=20counter=20mid=0D=0A=20=20=20=20movf=20=20=20Temp_mid,=20w=20= =20=20=20=20=20=20=20;=20else=20just=20get=20counter=20mid=0D=0A=20=20=20= =20addwf=20=20bres_mid,f=20=20=20=20=20=20=20=20=20;=20add=20to=20= bres-accu=20mid=0D=0A=20=20=20=20skpnc=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20;=20=0D=0A=20=20=20=20incf=20=20=20bres_hi,f=20= =20=20=20=20=20=20=20=20=20;=20if=20overflow=20add=201=20to=20bres-accu=20= hi=0D=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20;=20do=201=20sec=20stuff=20here=0D=0A=09= ;-------------------------=0D=0A=09=09=09=09=20=20=20=20=20=20=20=20;=20= now=20we=20do=20the=20"event"=20that=20we=20do=20every=20one=20second.=0D= =0A=09=09=09=09=20=20=20=20=20=20=20=20;=20Add=20your=20own=20code=20= here=20for=20your=20one=20second=20event.=0D=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=0D=0A=20=20=20=20=20=20= movf=20XorMask,w=20=20=20=20=20=20=20;=20get=20LED=20Mask=0D=0A=20=20=20=20= =20xorwf=20GPIO,f=20=20=20=20=20=20=20=20=20=20;=20xor=20(toggle)=20LED=20= bit=20&=20move=20to=20shadow=20reg=0D=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20move=20to=20GPIO=20= and=20out=20to=20LED=0D=0A=20=20=20=20;=0D=0A=20=20=20=20=20movlw=20=20= 0x01=09=09=20=20=20;=20set=20rollover=20flag=0D=0A=20=20=20=20=20movwf=20= =20rlovrflag=0D=0A=09;=0D=0A=09= ;-------------------------------------------------=0D=0A=09;=20now=20our=20= one=20second=20event=20is=20all=20done,=20we=20can=20exit=20the=0D=0A=09= ;=20interrupt=20handler.=0D=0A=09= ;-------------------------------------------------=0D=0A=09=20=20goto=20=20= iServ_Exit=20=20=20=09=09=09=20=20=20=20=20=20=20=20=0D=0A;=0D=0A= ServiceTimer0=0D=0A;=20just=20clear=20TMRO=20int=20flag=0D=0A;=0D=0A=20=20= =20=20=20=20=20bcf=20INTCON,T0IF=0D=0A;=0D=0A;=20=20=20=20=20movlw=20'T'=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0D=0A;=09=20movwf=20serdata=20= =20=20=20=20=20=20=20=20=20=20=20=20=0D=0A;=09=20=20call=20serxmt=0D=0A;=0D= =0AiServ_Exit=0D=0A;=20=20=20=20bcf=20=20=20=20=20INTCON,T0IF=20=20=20=20= =20;=20flag=20must=20be=20cleared=20in=20software=0D=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20= ready=20for=20next=20inerrupt=0D=0A;=20context=20saving=20is=20not=20= necessary=20with=20this=20program=0D=0A;=0D=0A=20=20=20=20movf=20=20=20=20= status_temp,w=20=20=20=20;=20retrieve=20copy=20of=20STATUS=20register=0D=0A= =20=20=20=20movwf=20=20=20STATUS=20=20=20=20=20=20=20=20=20=20=20;=20= restore=20pre-isr=20STATUS=20register=20contents=0D=0A=20=20=20=20swapf=20= =20=20w_temp,f=0D=0A=20=20=20=20swapf=20=20=20w_temp,w=20=20=20=20=20=20=20= =20=20;=20restore=20pre-isr=20W=20register=20contents=0D=0A;=0D=0A=20=20=20= =20retfie=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20= return=20from=20interrupt=0D=0A;=0D=0A;=20End=20of=20Interrupt=20Service=20= Routine=0D=0A= ;_________________________________________________________________________= _________=0D=0A;=0D=0A=20=20=20=20END=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20;=20directive=20'end=20of=20program'=0D=0A=0D=0A=0D=0A=0D=0A= --Apple-Mail-4-559188363 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-4-559188363 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --Apple-Mail-4-559188363--