<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE codeDefinitions SYSTEM "../codeDefinitions.dtd">

<codeDefinitions>
  <codeBlock>

    <code name="fuses" caption="fuses (DCR) configuration">
      <line comment="B15:14=FSCKM1:0 B9:8=FOS1:0 B3:0=FPR3:0"></line>
      <line register="FOSC" action="WCFG" mask="0xFFFF" comment=""></line>
      <line comment="B15=FWDTEN B5:4=FWPSA1:0 B3:0=FWPSB3:0"></line>
      <line register="FWDT" action="WCFG" mask="0xFFFF" comment=""></line>
      <line comment="B15=MCLREN B10=PWMPIN B9=HPOL B8=LPOL"></line>
    </code>

    <code name="Interrupts" caption="Disable Interrupts during configuration">
      <line comment="clear int flags:"></line>
      <line comment="B15=CN B14=BCL B13=I2C B12=NVM B11=AD B10=U1TX B9=U1RX B8=SPI1"></line>
      <line comment="B7=T3 B6=T2 B5=OC2 B4=IC2 B3=T1 B2=OC1 B1=IC1 B0=INT0"></line>
      <line register="IFS0" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
      <line comment="B15:12=IC6:3 B11=C1 B10=SPI2 B9=U2TX B8=U2RX"></line>
      <line comment="B7=INT2 B6=T5 B5=T4 B4=OC4 B3=OC3 B2=IC8 B1=IC7 B0=INT1"></line>
      <line register="IFS1" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
      <line comment="B12=FLTB B11=FLTA B10=LVD B9=DCI B8=QEI"></line>
      <line comment="B7=PWM B6=C2 B5=INT4 B4=INT3 B3:0=OC8:5"></line>
      <line register="IFS2" action="W" value="0x0000" mask="0x1FFF" comment=""></line>
      <line register="IEC0" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
      <line register="IEC1" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
      <line register="IEC2" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
    </code>

    <code name="Reset" caption="Reset configuration">
      <line comment="B15=TRAPR B14=IOPWR B13=BGST B12=LVDEN B11:8=LVDL3:0"></line>
      <line comment="B7=EXTR B6=SWR B5=SWDTEN B4=WDTO B3=SLEEP B2=IDLE B1=BOR B0=POR"></line>
      <line register="RCON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="DSP" caption="DSP core configuration">
      <line comment="B11=EDT B10:8=DL2:0 B7=SATA B6=SATB B5=SATDW"></line>
      <line comment="B4=ACCSAT B3=IPL3 B2=PSV B1=RND B0=IF"></line>
      <line register="CORCON" action="WREG" mask="0xFFFB"  RWMEnabled="true" comment=""></line>
    </code>

    <code name="NVM" caption="NVM configuration - not implemented">
    </code>

    <code name="Oscillator" caption="Oscillator configuration">
      <line comment="method to override OSCCON write protect"></line>
      <line comment="B13:12=COSC1:0 B9:8=NOSC1:0"></line>
      <line register="OSCCON" action="LREG.b_H" value="WREG" mask="0x00FF" comment=""></line>
      <line register="W1" action="W.b_H" value="0x78" mask="0x00FF" comment=""></line>
      <line register="W2" action="W.b_H" value="0x9A" mask="0x00FF" comment=""></line>
      <line code="MOV.W #OSCCON, W3" comment=""></line>

      <line code="MOV.B W1, [W3+1]" comment=""></line>
      <line code="MOV.B W2, [W3+1]" comment=""></line>
      <line code="MOV.B W0, [W3+1]" comment=""></line>

      <line comment="B7:6=POST1:0 B5=LOCK B3=CF B1=LPOSCEN B0=OSWEN"></line>
      <line register="OSCCON" action="LREG.b_L" value="WREG" mask="0x00FF" comment=""></line>
      <line register="W1" action="W.b_L" value="0x46" mask="0x00FF" comment=""></line>
      <line register="W2" action="W.b_L" value="0x57" mask="0x00FF" comment=""></line>

      <line code="MOV.B W1, [W3+0]" comment=""></line>
      <line code="MOV.B W2, [W3+0]" comment=""></line>
      <line code="MOV.B W0, [W3+0]" comment=""></line>
    </code>

    <code name="A2D" caption="A2D configuration">
      <line register="ADPCFG" action="W" value="0xFFFF" mask="0xFFFF" comment="force all A2D ports to digital IO at first"></line>
    </code>

    <code name="IOPortA" caption="IO Ports configuration">
      <line comment="B15:0=A15:0"></line>
      <line register="PORTA" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISA" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="IOPortB" caption="IO Ports configuration">
      <line comment="B15:0=B15:0"></line>
      <line register="PORTB" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISB" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="IOPortD" caption="IO Ports configuration">
      <line comment="B15:0=D15:0"></line>
      <line register="PORTD" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISD" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="IOPortE" caption="IO Ports configuration">
      <line comment="B15:0=D15:0"></line>
      <line register="PORTE" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISE" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="IOPortF" caption="IO Ports configuration">
      <line comment="B15:0=F15:0"></line>
      <line register="PORTF" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISF" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="IOPortG" caption="IO Ports configuration">
      <line comment="B15:0=G15:0"></line>
      <line register="PORTG" action="WREG" mask="0xFFFF" comment="enable"></line>
      <line register="TRISG" action="WREG" mask="0xFFFF" comment="direction in=1"></line>
    </code>

    <code name="CN1" caption="Input Change Notification configuration">
      <line comment="B15:0=CN15:0"></line>
      <line register="CNEN1" action="WREG" mask="0xFFFF" comment="enable change notification"></line>
      <line register="CNPU1" action="WREG" mask="0xFFFF" comment="enable pullup change notification"></line>
    </code>

    <code name="Timer1" caption="Timers configuration">
      <line register="T1CON" action="W" value="0x0000" mask="0xFFFF" comment="stop timer"></line>
    </code>

    <code name="Timer2" caption="Timers configuration">
      <line register="T2CON" action="W" value="0x0000" mask="0xFFFF" comment="stop timer"></line>
    </code>

    <code name="Timer3" caption="Timers configuration">
      <line register="T3CON" action="W" value="0x0000" mask="0xFFFF" comment="stop timer"></line>
    </code>

    <code name="Timer1" caption="Timers configuration">
      <line register="TMR1" action="WREG" mask="0xFFFF" comment="timer register"></line>
      <line register="PR1" action="WREG" mask="0xFFFF" comment="period register"></line>
    </code>

    <code name="Timer3" caption="Timers configuration">
      <line register="TMR3" action="WREG" mask="0xFFFF" comment="timer register"></line>
      <line register="TMR3HLD" action="WREG" mask="0xFFFF" comment="timer holding register for 32bit"></line>
      <line register="PR3" action="WREG" mask="0xFFFF" comment="period register"></line>
    </code>

    <code name="Timer2" caption="Timers configuration">
      <line register="TMR2" action="WREG" mask="0xFFFF" comment="timer register"></line>
      <line register="PR2" action="WREG" mask="0xFFFF" comment="period register"></line>
    </code>

    <code name="IC1" caption="Input Capture configuration">
      <line comment="B13=ICSDL B7=ICTMR B6:5=ICI1:0 B4=ICOV B3=ICBNE B2:0=ICM2:0"></line>
      <line register="IC1CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="OC1" caption="Turn off OC1 thru OC8">
      <line comment="associated timers need to be turned off first"></line>
      <line register="OC1CON" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
    </code>

    <code name="OC2" caption="Turn off OC1 thru OC8">
      <line comment="associated timers need to be turned off first"></line>
      <line register="OC2CON" action="W" value="0x0000" mask="0xFFFF" comment=""></line>
    </code>

    <code name="OC1" caption="Output Compare configuration">
      <line comment="OCnRS:  output compare n secondary register"></line>
      <line comment="OCnR:   output compare 1 main register"></line>
      <line comment="OCnCON: B13=OCSIDL B4=OCFLT B3=OCTSEL B2:0=OCM2:0"></line>

      <line register="OC1RS" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="OC1R" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="OC1CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="OC2" caption="Output Compare configuration">
      <line comment="OCnRS:  output compare n secondary register"></line>
      <line comment="OCnR:   output compare 1 main register"></line>
      <line comment="OCnCON: B13=OCSIDL B4=OCFLT B3=OCTSEL B2:0=OCM2:0"></line>

      <line register="OC2RS" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="OC2R" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="OC2CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="SPI1" caption="SPI configuration">
      <line comment="SPInBUF:    SPI n buffer"></line>
      <line comment="SPInSTAT:   B15=SPIEN B13=SPISIDL B6=SPITBF B5=SPIROV B0=SPIRBF"></line>
      <line comment="SPInCON(H): B14=FRMEN B13=SPIFSD B11=DISSDO B10=MODE16 B9=SMP B8=CKE"></line>
      <line comment="SPInCON(L): B7=SSEN B6=CKP B5=MSTEN B4:2=SPRE2:0 B1:0=PPRE1:0"></line>

      <line register="SPI1BUF" action="R" mask="0xFFFF" comment=""></line>
      <line register="SPI1STAT" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="SPI1CON1" action="WREG" mask="0xFFFF" comment=""></line>
      <line register="SPI1CON2" action="WREG" mask="0xFFFF" comment=""></line>
      
    </code>

    <code name="I2C" caption="I2C configuration">
      <line comment="B7:0: receive register bits7:0"></line>
      <line register="I2CRCV" action="R" mask="0x01FF" comment=""></line>
      <line comment="B9:0: address register bits9:0"></line>
      <line register="I2CADD" action="WREG" mask="0x01FF" comment=""></line>
      <line comment="B8:0: baud rate generator bits 8:0"></line>
      <line register="I2CBRG" action="WREG" mask="0x01FF" comment=""></line>
      <line comment="B15=ACKSTAT B14=TRSTAT B10=BCL B9=GCSTAT B8=ADD10"></line>
      <line comment="B7=IWCOL B6=I2COV B5=D_A B4=P B3=S B2=R_W B1=RBF B0=TBF"></line>
      <line register="I2CSTAT" action="WREG" mask="0x01FF" comment=""></line>
      <line comment="B15=I2CEN B13=I2CSIDL B12=SCLREL B11=IPMIEN B10=A10M B9=DISSLW B8=SMEN"></line>
      <line comment="B7=GCEN B6=STREN B5=ACKDT B4=ACKEN B3=RCEN B2=PEN B1=RSEN B0=SEN"></line>
      <line register="I2CCON" action="WREG" mask="0x01FF" comment=""></line>
    </code>
    
    <code name="UART1" caption="UART 1 configuration">
      <line register="U1BRG" action="WREG" mask="0xFFFF" comment="UART1 baud rate generator"></line>
      <line comment="B15=UTXISEL B11=UTXBRK B10=UTXEN B9=UTXBF B8=TRMT"></line>
      <line comment="B7:6=URXISEL1:0 B5=ADDEN B4=RIDLE B3=PERR B2=FERR B1=OERR B0=URXDA"></line>
      <line register="U1MODE" action="W" value="0x8000" mask="0xFFFF" comment="enabling UART flushes buffers"></line>
      <line register="U1STA" action="WREG" mask="0xFFFF" comment=""></line>
      <line comment="B15=UARTEN B13=USIDL B10=ALTIO"></line>
      <line comment="B7=WAKE B6=LPBACK B5=ABAUD B2:1=PDSEL1:0 B0=STSEL"></line>
      <line register="U1MODE" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="A2D" caption="A2D configuration">

		<line comment="B15=ADON B13=ADSIDL B10=GSWTRG B8=FORM"></line>
		<line comment="B15=EIE B13=ORDER B10=SEQSAMP"></line>
		<line register="ADCON" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B11=PCFG11 B10=PCFG10 B9=PCFG9 B8=PCFG8"></line>
		<line comment="B7=PCFG7 B6=PCFG6 B5=PCFG5 B4=PCFG4"></line>
		<line comment="B3=PCFG3 B2=PCFG2 B1=PCFG1 B0=PCFG0"></line>
		<line register="ADPCFG" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=IRQEN1 B13=SWTRG1 B12:8=TRGSRC1"></line>
		<line comment="B7=IRQEN0 B5=SWTRG0 B4:0=TRGSRC0"></line>
		<line register="ADCPC0" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=IRQEN3 B13=SWTRG3 B12:8=TRGSRC3"></line>
		<line comment="B7=IRQEN2 B5=SWTRG2 B4:0=TRGSRC2"></line>
		<line register="ADCPC1" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15=IRQEN5 B13=SWTRG5 B12:8=TRGSRC5"></line>
		<line comment="B7=IRQEN4 B5=SWTRG4 B4:0=TRGSRC4"></line>
		<line register="ADCPC2" action="WREG" mask="0xFFFF" comment=""></line>
	
    </code>
    
    <code name="SMPSComp1" caption="SMPS Comparator configuration">
		<line comment="B15=CMPON B14=CMPISDL B7:6=INSEL B5=EXTREF"></line>
		<line comment="B3=CMPSTAT B1=CMPPOL B0=RANGE"></line>
		<line register="CMPCON1" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B9:0=CMREF"></line>
		<line register="CMPDAC1" action="WREG" mask="0xFFFF" comment=""></line>
	</code>

    <code name="SMPSComp2" caption="SMPS Comparator configuration">
		<line comment="B15=CMPON B14=CMPISDL B7:6=INSEL B5=EXTREF"></line>
		<line comment="B3=CMPSTAT B1=CMPPOL B0=RANGE"></line>
		<line register="CMPCON2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B9:0=CMREF"></line>
		<line register="CMPDAC2" action="WREG" mask="0xFFFF" comment=""></line>
	</code>

    <code name="SMPSComp3" caption="SMPS Comparator configuration">
		<line comment="B15=CMPON B14=CMPISDL B7:6=INSEL B5=EXTREF"></line>
		<line comment="B3=CMPSTAT B1=CMPPOL B0=RANGE"></line>
		<line register="CMPCON3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B9:0=CMREF"></line>
		<line register="CMPDAC3" action="WREG" mask="0xFFFF" comment=""></line>
	</code>
	
    <code name="SMPSComp4" caption="SMPS Comparator configuration">
		<line comment="B15=CMPON B14=CMPISDL B7:6=INSEL B5=EXTREF"></line>
		<line comment="B3=CMPSTAT B1=CMPPOL B0=RANGE"></line>
		<line register="CMPCON4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B9:0=CMREF"></line>
		<line register="CMPDAC4" action="WREG" mask="0xFFFF" comment=""></line>
	</code>
	
	<code name="SMPSPWM" caption="SMPS PWM Configuration">
		<line comment="B15=PTEN B13=PTSIDL B12=SESAT B11=SEIEN"></line>
		<line comment="B10=EIPU B9=SYNCPOL B8=SYNCOEN B7=SYNCEN"></line>
		<line comment="B6:4=SYNCSRC B3:0=SEVTPS"></line>
		<line register="PTCON" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:3 PTPER"></line>
		<line register="PTPER" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:3 MASTER DUTY CYCLE"></line>
		<line register="MDC" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:3 SEVTCMP"></line>
		<line register="SEVTCMP" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=FLTSTAT B14=CLSTAT B13=TRGSTAT B12=FLTIEN"></line>
		<line comment="B11=CLIEN B10=TRGIEN B9=ITB B8=MDCS"></line>
		<line comment="B7:6=DTC B1=XPRES B0=IUE"></line>
		<line register="PWMCON1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=PENH B14=PENL B13=POLH B12=POLL"></line>
		<line comment="B11:10=PMOD B9=OVRENH B8=OVRENL B7:6=OVRDAT"></line>
		<line comment="B5:4=FLDAT B3:2=CLDAT B0=OSYNC"></line>
		<line register="IOCON1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B12:9=CLSRC B8=CLPOL B7=CLMODE B6:3=FLTSRC"></line>
		<line comment="B2=FLTPOL B1:0=FLTMOD"></line>
		<line register="FCLCON1" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:0=PDC"></line>
		<line register="PDC1" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:2=PHASE"></line>
		<line register="PHASE1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:2=DTR"></line>
		<line register="DTR1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:2=ALTDTR"></line>
		<line register="ALTDTR1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:15=TRGCMP"></line>
		<line register="TRIG1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:13=TRGDIV B5:0=TRGSTRT"></line>
		<line register="TRIGCON1" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15=PHR B14=PHL B13=PLR B12=PLF"></line>
		<line comment="B11=FLTLEBEN B10=CLLEBEN B9:3=LEB"></line>
		<line register="LEBCON1" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=FLTSTAT B14=CLSTAT B13=TRGSTAT B12=FLTIEN"></line>
		<line comment="B11=CLIEN B10=TRGIEN B9=ITB B8=MDCS"></line>
		<line comment="B7:6=DTC B1=XPRES B0=IUE"></line>

		<line register="PWMCON2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=PENH B14=PENL B13=POLH B12=POLL"></line>
		<line comment="B11:10=PMOD B9=OVRENH B8=OVRENL B7:6=OVRDAT"></line>
		<line comment="B5:4=FLDAT B3:2=CLDAT B0=OSYNC"></line>
		<line register="IOCON2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B12:9=CLSRC B8=CLPOL B7=CLMODE B6:3=FLTSRC"></line>
		<line comment="B2=FLTPOL B1:0=FLTMOD"></line>
		<line register="FCLCON2" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:0=PDC"></line>
		<line register="PDC2" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:2=PHASE"></line>
		<line register="PHASE2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:2=DTR"></line>
		<line register="DTR2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:2=ALTDTR"></line>
		<line register="ALTDTR2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:15=TRGCMP"></line>
		<line register="TRIG2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:13=TRGDIV B5:0=TRGSTRT"></line>
		<line register="TRIGCON2" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15=PHR B14=PHL B13=PLR B12=PLF"></line>
		<line comment="B11=FLTLEBEN B10=CLLEBEN B9:3=LEB"></line>
		<line register="LEBCON2" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=FLTSTAT B14=CLSTAT B13=TRGSTAT B12=FLTIEN"></line>
		<line comment="B11=CLIEN B10=TRGIEN B9=ITB B8=MDCS"></line>
		<line comment="B7:6=DTC B1=XPRES B0=IUE"></line>
		<line register="PWMCON3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=PENH B14=PENL B13=POLH B12=POLL"></line>
		<line comment="B11:10=PMOD B9=OVRENH B8=OVRENL B7:6=OVRDAT"></line>
		<line comment="B5:4=FLDAT B3:2=CLDAT B0=OSYNC"></line>
		<line register="IOCON3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B12:9=CLSRC B8=CLPOL B7=CLMODE B6:3=FLTSRC"></line>
		<line comment="B2=FLTPOL B1:0=FLTMOD"></line>
		<line register="FCLCON3" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:0=PDC"></line>
		<line register="PDC3" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:2=PHASE"></line>
		<line register="PHASE3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:2=DTR"></line>
		<line register="DTR3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:2=ALTDTR"></line>
		<line register="ALTDTR3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:15=TRGCMP"></line>
		<line register="TRIG3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:13=TRGDIV B5:0=TRGSTRT"></line>
		<line register="TRIGCON3" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15=PHR B14=PHL B13=PLR B12=PLF"></line>
		<line comment="B11=FLTLEBEN B10=CLLEBEN B9:3=LEB"></line>
		<line register="LEBCON3" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=FLTSTAT B14=CLSTAT B13=TRGSTAT B12=FLTIEN"></line>
		<line comment="B11=CLIEN B10=TRGIEN B9=ITB B8=MDCS"></line>
		<line comment="B7:6=DTC B1=XPRES B0=IUE"></line>

		<line register="PWMCON4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15=PENH B14=PENL B13=POLH B12=POLL"></line>
		<line comment="B11:10=PMOD B9=OVRENH B8=OVRENL B7:6=OVRDAT"></line>
		<line comment="B5:4=FLDAT B3:2=CLDAT B0=OSYNC"></line>
		<line register="IOCON4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B12:9=CLSRC B8=CLPOL B7=CLMODE B6:3=FLTSRC"></line>
		<line comment="B2=FLTPOL B1:0=FLTMOD"></line>
		<line register="FCLCON4" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:0=PDC"></line>
		<line register="PDC4" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15:2=PHASE"></line>
		<line register="PHASE4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:2=DTR"></line>
		<line register="DTR4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:2=ALTDTR"></line>
		<line register="ALTDTR4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B13:15=TRGCMP"></line>
		<line register="TRIG4" action="WREG" mask="0xFFFF" comment=""></line>
		
		<line comment="B15:13=TRGDIV B5:0=TRGSTRT"></line>
		<line register="TRIGCON4" action="WREG" mask="0xFFFF" comment=""></line>

		<line comment="B15=PHR B14=PHL B13=PLR B12=PLF"></line>
		<line comment="B11=FLTLEBEN B10=CLLEBEN B9:3=LEB"></line>
		<line register="LEBCON4" action="WREG" mask="0xFFFF" comment=""></line>
		
	</code>
	
    <code name="required" caption="Interrupt flags cleared and interrupt configuration">
      <line comment="interrupt priorities IP"></line>
      <line comment="B14:12=T1 B10:8=OC1 B6:4=IC1 B2:0=INTO"></line>
      <line register="IPC0" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=T3 B10:8=T2 B6:4=OC2 B2:0=IC2"></line>
      <line register="IPC1" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=AD B10:8=U1TX B6:4=U1RX B2:0=SPI1"></line>
      <line register="IPC2" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=CN B10:8= BCLB6:4=I2C B2:0=NVM"></line>
      <line register="IPC3" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=OC3 B10:8=IC8 B6:4=IC7 B2:0=INT1"></line>
      <line register="IPC4" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=INT2 B10:8=T5 B6:4=T4 B2:0=OC4"></line>
      <line register="IPC5" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=C1 B10:8=SPI2 B6:4=U2TX B2:0=U2RX"></line>
      <line register="IPC6" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=IC6 B10:8=IC5 B6:4=IC4 B2:0=IC3"></line>
      <line register="IPC7" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=OC8 B10:8=OC7 B6:4=OC6 B2:0=OC5"></line>
      <line register="IPC8" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=PWM B10:8=C2 B6:4=INT4 B2:0=INT3"></line>
      <line register="IPC9" action="WREG" mask="0x7777" comment=""></line>
      <line comment="B14:12=FLTA B10:8=LVD B6:4=DCI B2:0=QEI"></line>
      <line register="IPC10" action="WREG" mask="0x7777" comment=""></line>
      <line comment="external interrupt enables"></line>
      <line comment="B15=NSTDIS B10=OVATE B9=OVBTE B8=COVTE"></line>
      <line comment="B4=MATHERR B3=ADDRERR B2=STKERR B1=OSCFAIL"></line>
      <line register="INTCON1" action="WREG" mask="0x801E" comment=""></line>
      <line comment="B15=ALTIVT B4:0=INTnEP4:0"></line>
      <line register="INTCON2" action="WREG" mask="0x801F" comment=""></line>
    </code>

    <code name="Timer1" caption="Start timers">
      <line comment="Timers1: B15=TON B13=TSIDL B6=TGATE B5:4=TCKPS1:0 B2=TSYNC B1=TCS"></line>
      <line register="T1CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="Timer3" caption="Start timers">
      <line comment="Timers3,5:   B15=TON B13=TSIDL B6=TGATE B5:4=TCKPS1:0 B1=TCS"></line>
      <line register="T3CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>

    <code name="Timer2" caption="Start timers">
      <line comment="Timers2,4:   B15=TON B13=TSIDL B6=TGATE B5:4=TCKPS1:0 B3=T32 B1=TCS"></line>
      <line register="T2CON" action="WREG" mask="0xFFFF" comment=""></line>
    </code>
    
    <code name="CPU" caption="CPU register configuration">
      <line register="SR" action="WMAN" value="0x0000" mask="0xFFFF" comment=""></line>
      <line register="SR" action="WREGMAN" mask="0xFFFF" comment=""></line>

      <line register="W0" action="WMAN" value="0x0000" mask="0xFFFF" comment=""></line>
      <line register="W1" action="WMAN" value="0x0000" mask="0xFFFF" comment=""></line>
      <line register="W2" action="WMAN" value="0x0000" mask="0xFFFF" comment=""></line>
    </code>

    <code name="Interrupts" caption="enable interrupts">
      <line comment="feature interrupt enables IE"></line>
      <line comment="B15=CN B14=BCL B13=I2C B12=NVM B11=AD B10=U1TX B9=U1RX B8=SPI1"></line>
      <line comment="B7=T3 B6=T2 B5=OC2 B4=IC2 B3=T1 B2=OC1 B1=IC1 B0=INT0"></line>
      <line register="IEC0" action="WREG" mask="0xFFFF" comment=""></line>

      <line comment="B15:12=IC6:3 B11=C1 B10=SPI2 B9=U2TX B8=U2RX"></line>
      <line comment="B7=INT2 B6=T5 B5=T4 B4=OC4 B3=OC3 B2=IC8 B1=IC7 B0=INT1"></line>
      <line register="IEC1" action="WREG" mask="0xFFFF" comment=""></line>

      <line comment="B12=FLTB B11=FLTA B10=LVD B9=DCI B8=QEI"></line>
      <line comment="B7=PWM B6=C2 B5=INT4 B4=INT3 B3:0=OC8:5"></line>
      <line register="IEC2" action="WREG" mask="0x1FFF" comment=""></line>

      <line code="return" comment="end of init"></line>
    </code>

  </codeBlock>
</codeDefinitions>