
format=0.1

#device=PIC12CE673

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

pgming (memtech=eprom ovrpgm=11 tries=8)
    wait (pgm=100 cfg=100 userid=100)

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


NumBanks=2
MirrorRegs (0x0-0x0 0x80-0x80)
MirrorRegs (0x02-0x04 0x82-0x84)
MirrorRegs (0x0a-0x0b 0x8a-0x8b)
MirrorRegs (0x70-0x7f 0xf0-0xff)
UnusedRegs (0x06-0x09)
UnusedRegs (0x0d-0x1d)
UnusedRegs (0x86-0x89)
UnusedRegs (0x8d-0x8d)
UnusedRegs (0x90-0x9e)
UnusedRegs (0xc0-0xef)


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=GPIO addr=0x5 size=1 access='u u rw rw r rw rw rw')
    reset (por='11xxxxxx' mclr='11uuuuuu')
    bit (names='SCL SDA GP5 GP4 GP3 GP2 GP1 GP0')
    bit (tag=scl names='GP' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)

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 PEIE TMR0IE INTE GPIE TMR0IF INTF GPIF')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=PIR1 addr=0xC size=1 access='u rw u u u u u u')
    reset (por='-0------' mclr='-0------')
    bit (names='- ADIF - - - - - -')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=ADRES addr=0x1E 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=ADCON0 addr=0x1F size=1 access='rw rw u rw rw rw u rw')
    reset (por='00000000' mclr='00000000')
    bit (names='ADCS - CHS GO/nDONE - ADON' width='2 1 2 1 1 1')
    bit (tag=scl names='ADCS - CHS GO_nDONE - ADON' width='2 1 2 1 1 1')
    stimulus (scl=rwb regfiles=w)

sfr (key=OPTION_REG addr=0x81 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='nGPPU INTEDG T0CS T0SE PSA PS' width='1 1 1 1 1 3')
    stimulus (scl=rwb regfiles=w)
sfr (key=TRIS addr=0x85 size=1 access='u u rw rw r rw rw rw')
# from DS: GP3, which is input only and its TRIS bit will always read as '1'
    reset (por='--111111' mclr='--111111')
    bit (names='- - TRIS5 TRIS4 TRIS3 TRIS2 TRIS1 TRIS0')
    bit (tag=scl names='TRIS' width='8')
    stimulus (scl=rwb regfiles=w)    
sfr (key=PIE1 addr=0x8C size=1 access='u rw u u u u u u')
    reset (por='-0------' mclr='-0------')
    bit (names='- ADIE - - - - - -')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=PCON addr=0x8E size=1 access='u u u u u u rw u')
    reset (por='------0-' mclr='------u-')
    bit (names='- - - - - - nPOR -')
    stimulus (scl=rwb regfiles=w)
sfr (key=OSCCAL addr=0x8F size=1 access='rw rw rw rw rw rw u u')
    reset (por='011100--' mclr='uuuuuu--')
    bit (names='CAL CALFST CALSLW - -' width='4 1 1 1 1')
    stimulus (scl=rwb regfiles=w)
sfr (key=ADCON1 addr=0x9F size=1 access='u u u u u rw rw rw')
    reset (por='-----000' mclr='-----000')
    bit (names='- - - - - PCFG' width='1 1 1 1 1 3')
    stimulus (scl=rwb regfiles=w)


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

cfgbits (key=CONFIG addr=0x2007 unused=0x0)
    field (key=OSC mask=0x7 desc="Oscillator")
        setting (req=0x7 value=0x7 desc="External RC Clockout")
        setting (req=0x7 value=0x6 desc="External RC No Clock")
        setting (req=0x7 value=0x5 desc="Internal RC Clockout")
        setting (req=0x7 value=0x4 desc="Internal RC No Clock")
        setting (req=0x7 value=0x2 desc="HS")
        setting (req=0x7 value=0x1 desc="XT")
        setting (req=0x7 value=0x0 desc="LP")
    field (key=WDT mask=0x8 desc="Watchdog Timer")
        setting (req=0x8 value=0x8 desc="On")
        setting (req=0x8 value=0x0 desc="Off")
    field (key=PUT mask=0x10 desc="Power Up Timer")
        setting (req=0x10 value=0x10 desc="Off")
        setting (req=0x10 value=0x0 desc="On")
    field (key=MCLRE mask=0x80 desc="Master Clear Enable")
        setting (req=0x80 value=0x80 desc="External")
        setting (req=0x80 value=0x0 desc="Internal")
    field (key=CP mask=0x3F60 desc="Code Protect")
        setting (req=0x3F60 value=0x3F60 desc="Off")
            checksum (type=0x0 protregion=0x00-0x00)
        setting (req=0x3F60 value=0x1520 desc="200:3FE")
            checksum (type=0x20 protregion=0x200-0x3FE)
        setting (req=0x3F60 value=0x0 desc="All")
            checksum (type=0x20 protregion=0x0-0x3FE)

                               # ------------#
#------------------------------# Peripherals #------------------------------------#
                               # ------------#
#--------------------------------------------------------------------------------
# 				GPIO
#--------------------------------------------------------------------------------
peripheral (key=GPIO sfrs='GPIO TRIS' type=port)
    iopin (key=GP0 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=GP1 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=GP2 dir=inout)
        extint (key=INT0 enreg=INTCON enmask=0x10 flgreg=INTCON flgmask=0x02 prireg=NONE primask=0x00)
    iopin (key=GP3 dir=in)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x01 cnkey=PORTIOC0)
    iopin (key=GP4 dir=inout)
    iopin (key=GP5 dir=inout)

#--------------------------------------------------------------------------------
# 				ADC
#--------------------------------------------------------------------------------
peripheral (key=ADC8 sfrs='ADCON0 ADCON1 ADRES')
    pinfunc (key=AN0 port=GP0 dir=in)
    pinfunc (key=AN1 port=GP1 dir=in)
    pinfunc (key=AN2 port=GP2 dir=in)
    pinfunc (key=AN3 port=GP4 dir=in)
    access (key=ADCON1 mode=AD_PCFG_MIDRANGE)
    interrupt (name=ADC enreg=PIE1 enmask=0x40 flgreg=PIR1 flgmask=0x40 prireg=NONE primask=0x00)

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

#--------------------------------------------------------------------------------
# 				OSC
#--------------------------------------------------------------------------------

peripheral (key=OSC)
    pinfunc (key=OSC2 port=GP4 dir=out)
    pinfunc (key=OSC1 port=GP5 dir=in)
#    pinfunc (key=T1OSCI port= dir=in)
#        nextp (nextperiph=CCP2 nextpin=CCP2)
#    pinfunc (key=T1OSCO port= dir=out)
#        nextp (nextperiph=TMR1 nextpin=T1CKI)

#--------------------------------------------------------------------------------
# 				MCLR
#--------------------------------------------------------------------------------
peripheral (key=MCLR)
    pinfunc (key=MCLR port=GP3 dir=in)

#--------------------------------------------------------------------------------
# 				CORE
#--------------------------------------------------------------------------------
peripheral (key=CORE sfrs='PCON')
