
format=0.1

#device=PIC16C71

vpp (range=12.750-13.250  dflt=13.000)
vdd (range=3.000-5.500  dfltrange=4.500-5.500  nominal=5.000)

pgming (memtech=eprom ovrpgm=3 tries=25 csumadd=0x0060)
    wait (pgm=100 cfg=100 userid=100)

pgmmem (region=0x00-0x3FF)
cfgmem (region=0x2007-0x2007)
testmem (region=0x2000-0x207F)
userid (region=0x2000-0x2003)


NumBanks=2
MirrorRegs (0x0-0x0 0x80-0x80)
MirrorRegs (0x02-0x04 0x82-0x84)
MirrorRegs (0x09-0x2f 0x89-0xaf)
UnusedRegs (0x7-0x7)
UnusedRegs (0x87-0x87)
UnusedRegs (0x30-0x7f)
UnusedRegs (0xb0-0xff)


sfr (key=INDF addr=0x0 size=1 flags=i access='u u u u u u u u')
    reset (por='--------' mclr='--------')
    bit (names='INDF' width='8')
sfr (key=TMR0 addr=0x1 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='TMR0' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)
sfr (key=PCL addr=0x2 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='PCL' width='8')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=STATUS addr=0x3 size=1 access='r r rw r r rw rw rw')
    reset (por='00011xxx' mclr='000qquuu')
    bit (names='IRP RP nTO nPD Z DC C' width='1 2 1 1 1 1 1')

sfr (key=FSR addr=0x4 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='FSR' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=rw)
sfr (key=PORTA addr=0x5 size=1 access='u u u rw rw rw rw rw')
    reset (por='---x0000' mclr='---u0000')
    bit (names='- - - RA4 RA3 RA2 RA1 RA0')
    bit (tag=scl names='RA' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTB addr=0x6 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0')
    bit (tag=scl names='RB' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=ADCON0 addr=0x8 size=1 access='rw rw u rw rw rw rw rw')
    reset (por='00-00000' mclr='00-00000')
    bit (names='ADCS - CHS GO/nDONE ADIF ADON' width='2 1 2 1 1 1')
    bit (tag=scl names='ADCS - CHS GO_nDONE ADIF ADON' width='2 1 2 1 1 1')
    stimulus (scl=rwb regfiles=w)
sfr (key=ADRES addr=0x09 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='ADRES' width='8')
    stimulus (scl=rwb type=int regfiles=r)
sfr (key=PCLATH addr=0xA size=1 access='u u u rw rw rw rw rw')
    reset (por='---00000' mclr='---00000')
    bit (names='- - - PCLATH' width='1 1 1 5')
    stimulus (scl=rwb type=int regfiles=w pcfiles=rw)
sfr (key=INTCON addr=0xB size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='0000000x' mclr='0000000u')
    bit (names='GIE ADIE T0IE INTE RBIE T0IF INTF RBIF')
    stimulus (scl=rwb regfiles=w pcfiles=rw)

sfr (key=OPTION_REG addr=0x81 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='nRBPU INTEDG T0CS T0SE PSA PS' width='1 1 1 1 1 3')
    stimulus (scl=rwb regfiles=w)
sfr (key=TRISA addr=0x85 size=1 access='u u u rw rw rw rw rw')
    reset (por='---11111' mclr='---11111')
    bit (names='- - - TRISA4 TRISA3 TRISA2 TRISA1 TRISA0')
    bit (tag=scl names='TRISA' width='8')
    stimulus (scl=rwb regfiles=w)    
sfr (key=TRISB addr=0x86 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0')
    bit (tag=scl names='TRISB' width='8')
    stimulus (scl=rwb regfiles=w)    
sfr (key=ADCON1 addr=0x88 size=1 access='u u u u u u rw rw')
    reset (por='------00' mclr='------00')
    bit (names='- - - - - - PCFG' width='1 1 1 1 1 1 2')
    stimulus (scl=rwb regfiles=w)


                               # -------------------#
#------------------------------# Configuration Bits #------------------------------------#
                               # -------------------#

cfgbits (key=CONFIG addr=0x2007 unused=0x3FE0)
    field (key=OSC mask=0x3 desc="Oscillator")
        setting (req=0x3 value=0x3 desc="RC")
        setting (req=0x3 value=0x0 desc="LP")
        setting (req=0x3 value=0x1 desc="XT")
        setting (req=0x3 value=0x2 desc="HS")
    field (key=WDT mask=0x4 desc="Watchdog Timer")
        setting (req=0x4 value=0x4 desc="On")
        setting (req=0x4 value=0x0 desc="Off")
    field (key=PUT mask=0x8 desc="Power Up Timer")
        setting (req=0x8 value=0x8 desc="On")
        setting (req=0x8 value=0x0 desc="Off")
    field (key=CP mask=0x10 desc="Code Protect")
        setting (req=0x10 value=0x10 desc="Off")
            checksum (type=0x40 protregion=0x00-0x00)
        setting (req=0x10 value=0x0 desc="On")
            checksum (type=0x12 protregion=0x40-0x3FF)

                               # ------------#
#------------------------------# Peripherals #------------------------------------#
                               # ------------#

#--------------------------------------------------------------------------------
# 				PORTA
#--------------------------------------------------------------------------------
peripheral (key=PORTA sfrs='TRISA PORTA' type=port)
    iopin (key=RA0 dir=inout)
    iopin (key=RA1 dir=inout)
    iopin (key=RA2 dir=inout)
    iopin (key=RA3 dir=inout)
    iopin (key=RA4 dir=inout)

#--------------------------------------------------------------------------------
# 				PORTB
#--------------------------------------------------------------------------------
peripheral (key=PORTB sfrs='TRISB PORTB' type=port)
    iopin (key=RB0 dir=inout)
        extint (key=INT0 enreg=INTCON enmask=0x10 flgreg=INTCON flgmask=0x02 prireg=NONE primask=0x00)
    iopin (key=RB1 dir=inout)
    iopin (key=RB2 dir=inout)
    iopin (key=RB3 dir=inout)
    iopin (key=RB4 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=RB5 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=RB6 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=RB7 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)


#--------------------------------------------------------------------------------
# 				ADC
#--------------------------------------------------------------------------------
peripheral (key=ADC8 sfrs='ADCON0 ADCON1 ADRES')
    pinfunc (key=AN0 port=RA0 dir=in)
    pinfunc (key=AN1 port=RA1 dir=in)
    pinfunc (key=AN2 port=RA2 dir=in)
    pinfunc (key=AN3 port=RA3 dir=in)
    access (key=ADCON1 mode=AD_PCFG_MIDRANGE_4)
    interrupt (name=ADC enreg=INTCON enmask=0x40 flgreg=ADCON0 flgmask=0x02 prireg=NONE primask=0x00)



#--------------------------------------------------------------------------------
# 				TIMERs
#--------------------------------------------------------------------------------
peripheral (key=TMR0 sfrs='TMR0')
    pinfunc (key=T0CKI port=RA4 dir=in)
    interrupt (name=TMR0INT enreg=INTCON enmask=0x20 flgreg=INTCON flgmask=0x04 prireg=NONE primask=0x00)

#--------------------------------------------------------------------------------
# 				CORE
#--------------------------------------------------------------------------------
peripheral (key=CORE)
