-- =================================================== -- Title: JalV2 device include file for PIC 16F716 -- -- Author: Rob Hamerling, Copyright (c) 2008..2010, all rights reserved. -- -- Adapted-by: -- -- Compiler: 2.4n -- -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) -- -- Description: -- Device include file for pic16f716, containing: -- - Declaration of ports and pins of the chip. -- - Procedures for shadowing of ports and pins -- to circumvent the read-modify-write problem. -- - Symbolic definitions for configuration bits (fuses) -- - Some device dependent procedures for common -- operations, like: -- . enable_digital_io() -- -- Sources: -- - x:/mplab856/mplab ide/device/pic16f716.dev -- - x:/mplab856/MPASM Suite/LKR/16f716_g.lkr -- -- Notes: -- - Created with Dev2Jal Rexx script version 0.1.05 -- - File creation date/time: 5 Sep 2010 09:06 -- -- =================================================== -- const word DEVICE_ID = 0x1140 const byte PICTYPE[] = "16F716" const byte DATASHEET[] = "41206" const byte PGMSPEC[] = "40245" -- -- Vdd Range: 2.000-5.500 Nominal: 5.000 -- Vpp Range: 10.000-12.000 Default: 11.000 -- -- --------------------------------------------------- -- include chipdef_jallib -- common constants -- pragma target cpu PIC_14 -- (banks=2) pragma target chip 16f716 pragma target bank 0x0080 pragma target page 0x0800 pragma stack 8 pragma code 2048 -- (words) pragma ID 0x2000,4 pragma data 0x20-0x6F,0xA0-0xBF pragma shared 0x70-0x7F -- var volatile byte _pic_accum shared at 0x7E -- (compiler) var volatile byte _pic_isr_w shared at 0x7F -- (compiler) -- const word _FUSES_CT = 1 const word _FUSE_BASE = 0x2007 const word _FUSES = 0b_0011_1111_1111_1111 -- -- ------------------------------------------------ var volatile byte INDF at { 0x0,0x80 } var volatile byte _ind at { 0x0,0x80 } -- (compiler) -- ------------------------------------------------ var volatile byte TMR0 at { 0x1 } -- ------------------------------------------------ var volatile byte PCL at { 0x2,0x82 } var volatile byte _pcl at { 0x2,0x82 } -- (compiler) -- ------------------------------------------------ var volatile byte STATUS at { 0x3,0x83 } var volatile bit STATUS_IRP at STATUS : 7 var volatile bit*2 STATUS_RP at STATUS : 5 var volatile bit STATUS_NTO at STATUS : 4 var volatile bit STATUS_NPD at STATUS : 3 var volatile bit STATUS_Z at STATUS : 2 var volatile bit STATUS_DC at STATUS : 1 var volatile bit STATUS_C at STATUS : 0 var volatile byte _status at { 0x3,0x83 } -- (compiler) const byte _irp = 7 -- (compiler) const byte _rp1 = 6 -- (compiler) const byte _rp0 = 5 -- (compiler) const byte _not_to = 4 -- (compiler) const byte _not_pd = 3 -- (compiler) const byte _z = 2 -- (compiler) const byte _dc = 1 -- (compiler) const byte _c = 0 -- (compiler) -- ------------------------------------------------ var volatile byte FSR at { 0x4,0x84 } var volatile byte _fsr at { 0x4,0x84 } -- (compiler) -- ------------------------------------------------ var volatile byte PORTA at { 0x5 } -- var byte _PORTA_shadow = PORTA -- procedure _PORTA_flush() is pragma inline PORTA = _PORTA_shadow end procedure procedure PORTA'put(byte in x) is pragma inline _PORTA_shadow = x _PORTA_flush() end procedure -- procedure PORTA_low'put(byte in x) is pragma inline _PORTA_shadow = (_PORTA_shadow & 0xF0) | (x & 0x0F) _PORTA_flush() end procedure function PORTA_low'get() return byte is pragma inline return (PORTA & 0x0F) end function -- procedure PORTA_high'put(byte in x) is pragma inline _PORTA_shadow = (_PORTA_shadow & 0x0F) | (x << 4) _PORTA_flush() end procedure function PORTA_high'get() return byte is pragma inline return (PORTA >> 4) end function -- var volatile bit PORTA_RA4 at PORTA : 4 var volatile bit pin_A4 at PORTA : 4 alias pin_T0CKI is pin_A4 -- procedure pin_A4'put(bit in x at _PORTA_shadow : 4) is pragma inline _PORTA_flush() end procedure -- var volatile bit PORTA_RA3 at PORTA : 3 var volatile bit pin_A3 at PORTA : 3 alias pin_AN3 is pin_A3 alias pin_VREF is pin_A3 -- procedure pin_A3'put(bit in x at _PORTA_shadow : 3) is pragma inline _PORTA_flush() end procedure -- var volatile bit PORTA_RA2 at PORTA : 2 var volatile bit pin_A2 at PORTA : 2 alias pin_AN2 is pin_A2 -- procedure pin_A2'put(bit in x at _PORTA_shadow : 2) is pragma inline _PORTA_flush() end procedure -- var volatile bit PORTA_RA1 at PORTA : 1 var volatile bit pin_A1 at PORTA : 1 alias pin_AN1 is pin_A1 -- procedure pin_A1'put(bit in x at _PORTA_shadow : 1) is pragma inline _PORTA_flush() end procedure -- var volatile bit PORTA_RA0 at PORTA : 0 var volatile bit pin_A0 at PORTA : 0 alias pin_AN0 is pin_A0 -- procedure pin_A0'put(bit in x at _PORTA_shadow : 0) is pragma inline _PORTA_flush() end procedure -- -- ------------------------------------------------ var volatile byte PORTB at { 0x6 } -- var byte _PORTB_shadow = PORTB -- procedure _PORTB_flush() is pragma inline PORTB = _PORTB_shadow end procedure procedure PORTB'put(byte in x) is pragma inline _PORTB_shadow = x _PORTB_flush() end procedure -- procedure PORTB_low'put(byte in x) is pragma inline _PORTB_shadow = (_PORTB_shadow & 0xF0) | (x & 0x0F) _PORTB_flush() end procedure function PORTB_low'get() return byte is pragma inline return (PORTB & 0x0F) end function -- procedure PORTB_high'put(byte in x) is pragma inline _PORTB_shadow = (_PORTB_shadow & 0x0F) | (x << 4) _PORTB_flush() end procedure function PORTB_high'get() return byte is pragma inline return (PORTB >> 4) end function -- var volatile bit PORTB_RB7 at PORTB : 7 var volatile bit pin_B7 at PORTB : 7 alias pin_P1D is pin_B7 -- procedure pin_B7'put(bit in x at _PORTB_shadow : 7) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB6 at PORTB : 6 var volatile bit pin_B6 at PORTB : 6 alias pin_P1C is pin_B6 -- procedure pin_B6'put(bit in x at _PORTB_shadow : 6) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB5 at PORTB : 5 var volatile bit pin_B5 at PORTB : 5 alias pin_P1B is pin_B5 -- procedure pin_B5'put(bit in x at _PORTB_shadow : 5) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB4 at PORTB : 4 var volatile bit pin_B4 at PORTB : 4 alias pin_ECCPAS0 is pin_B4 -- procedure pin_B4'put(bit in x at _PORTB_shadow : 4) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB3 at PORTB : 3 var volatile bit pin_B3 at PORTB : 3 alias pin_CCP1 is pin_B3 alias pin_P1A is pin_B3 -- procedure pin_B3'put(bit in x at _PORTB_shadow : 3) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB2 at PORTB : 2 var volatile bit pin_B2 at PORTB : 2 alias pin_T1OSI is pin_B2 -- procedure pin_B2'put(bit in x at _PORTB_shadow : 2) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB1 at PORTB : 1 var volatile bit pin_B1 at PORTB : 1 alias pin_T1OSO is pin_B1 alias pin_T1CKI is pin_B1 -- procedure pin_B1'put(bit in x at _PORTB_shadow : 1) is pragma inline _PORTB_flush() end procedure -- var volatile bit PORTB_RB0 at PORTB : 0 var volatile bit pin_B0 at PORTB : 0 alias pin_ECCPAS2 is pin_B0 -- procedure pin_B0'put(bit in x at _PORTB_shadow : 0) is pragma inline _PORTB_flush() end procedure -- -- ------------------------------------------------ var volatile byte PCLATH at { 0xA,0x8A } var volatile bit*5 PCLATH_PCLATH at PCLATH : 0 var volatile byte _pclath at { 0xA,0x8A } -- (compiler) -- ------------------------------------------------ var volatile byte INTCON at { 0xB,0x8B } var volatile bit INTCON_GIE at INTCON : 7 var volatile bit INTCON_PEIE at INTCON : 6 var volatile bit INTCON_TMR0IE at INTCON : 5 var volatile bit INTCON_INTE at INTCON : 4 var volatile bit INTCON_RBIE at INTCON : 3 var volatile bit INTCON_TMR0IF at INTCON : 2 var volatile bit INTCON_INTF at INTCON : 1 var volatile bit INTCON_RBIF at INTCON : 0 -- ------------------------------------------------ var volatile byte PIR1 at { 0xC } var volatile bit PIR1_ADIF at PIR1 : 6 var volatile bit PIR1_CCP1IF at PIR1 : 2 var volatile bit PIR1_TMR2IF at PIR1 : 1 var volatile bit PIR1_TMR1IF at PIR1 : 0 -- ------------------------------------------------ var volatile word TMR1 at { 0xE } -- ------------------------------------------------ var volatile byte TMR1L at { 0xE } -- ------------------------------------------------ var volatile byte TMR1H at { 0xF } -- ------------------------------------------------ var volatile byte T1CON at { 0x10 } var volatile bit*2 T1CON_T1CKPS at T1CON : 4 var volatile bit T1CON_T1OSCEN at T1CON : 3 var volatile bit T1CON_NT1SYNC at T1CON : 2 var volatile bit T1CON_TMR1CS at T1CON : 1 var volatile bit T1CON_TMR1ON at T1CON : 0 -- ------------------------------------------------ var volatile byte TMR2 at { 0x11 } -- ------------------------------------------------ var volatile byte T2CON at { 0x12 } var volatile bit*4 T2CON_TOUTPS at T2CON : 3 var volatile bit T2CON_TMR2ON at T2CON : 2 var volatile bit*2 T2CON_T2CKPS at T2CON : 0 -- ------------------------------------------------ var volatile word CCPR1 at { 0x15 } -- ------------------------------------------------ var volatile byte CCPR1L at { 0x15 } -- ------------------------------------------------ var volatile byte CCPR1H at { 0x16 } -- ------------------------------------------------ var volatile byte CCP1CON at { 0x17 } var volatile bit*2 CCP1CON_P1M at CCP1CON : 6 var volatile bit*2 CCP1CON_DC1B at CCP1CON : 4 var volatile bit*4 CCP1CON_CCP1M at CCP1CON : 0 -- ------------------------------------------------ var volatile byte PWM1CON at { 0x18 } var volatile bit PWM1CON_PRSEN at PWM1CON : 7 var volatile bit*7 PWM1CON_PDC at PWM1CON : 0 -- ------------------------------------------------ var volatile byte ECCPAS at { 0x19 } var volatile bit ECCPAS_ECCPASE at ECCPAS : 7 var volatile bit ECCPAS_ECCPAS2 at ECCPAS : 6 var volatile bit ECCPAS_ECCPAS0 at ECCPAS : 4 var volatile bit*2 ECCPAS_PSSAC at ECCPAS : 2 var volatile bit*2 ECCPAS_PSSBD at ECCPAS : 0 -- ------------------------------------------------ var volatile byte ADRES at { 0x1E } -- ------------------------------------------------ var volatile byte ADCON0 at { 0x1F } var volatile bit*2 ADCON0_ADCS at ADCON0 : 6 var volatile bit*3 ADCON0_CHS at ADCON0 : 3 var volatile bit ADCON0_GO at ADCON0 : 2 var volatile bit ADCON0_NDONE at ADCON0 : 2 var volatile bit ADCON0_ADON at ADCON0 : 0 -- ------------------------------------------------ var volatile byte OPTION_REG at { 0x81 } var volatile bit OPTION_REG_NRBPU at OPTION_REG : 7 var volatile bit OPTION_REG_INTEDG at OPTION_REG : 6 var volatile bit OPTION_REG_T0CS at OPTION_REG : 5 alias T0CON_T0CS is OPTION_REG_T0CS var volatile bit OPTION_REG_T0SE at OPTION_REG : 4 alias T0CON_T0SE is OPTION_REG_T0SE var volatile bit OPTION_REG_PSA at OPTION_REG : 3 alias T0CON_PSA is OPTION_REG_PSA var volatile bit*3 OPTION_REG_PS at OPTION_REG : 0 alias T0CON_T0PS is OPTION_REG_PS -- ------------------------------------------------ var volatile byte TRISA at { 0x85 } var volatile byte PORTA_direction at TRISA -- procedure PORTA_low_direction'put(byte in x) is pragma inline TRISA = (TRISA & 0xF0) | (x & 0x0F) end procedure function PORTA_low_direction'get() return byte is pragma inline return (TRISA & 0x0F) end function -- procedure PORTA_high_direction'put(byte in x) is pragma inline TRISA = (TRISA & 0x0F) | (x << 4) end procedure function PORTA_high_direction'get() return byte is pragma inline return (TRISA >> 4) end function -- var volatile bit TRISA_TRISA4 at TRISA : 4 var volatile bit pin_A4_direction at TRISA : 4 alias pin_T0CKI_direction is pin_A4_direction -- var volatile bit TRISA_TRISA3 at TRISA : 3 var volatile bit pin_A3_direction at TRISA : 3 alias pin_AN3_direction is pin_A3_direction alias pin_VREF_direction is pin_A3_direction -- var volatile bit TRISA_TRISA2 at TRISA : 2 var volatile bit pin_A2_direction at TRISA : 2 alias pin_AN2_direction is pin_A2_direction -- var volatile bit TRISA_TRISA1 at TRISA : 1 var volatile bit pin_A1_direction at TRISA : 1 alias pin_AN1_direction is pin_A1_direction -- var volatile bit TRISA_TRISA0 at TRISA : 0 var volatile bit pin_A0_direction at TRISA : 0 alias pin_AN0_direction is pin_A0_direction -- -- ------------------------------------------------ var volatile byte TRISB at { 0x86 } var volatile byte PORTB_direction at TRISB -- procedure PORTB_low_direction'put(byte in x) is pragma inline TRISB = (TRISB & 0xF0) | (x & 0x0F) end procedure function PORTB_low_direction'get() return byte is pragma inline return (TRISB & 0x0F) end function -- procedure PORTB_high_direction'put(byte in x) is pragma inline TRISB = (TRISB & 0x0F) | (x << 4) end procedure function PORTB_high_direction'get() return byte is pragma inline return (TRISB >> 4) end function -- var volatile bit TRISB_TRISB7 at TRISB : 7 var volatile bit pin_B7_direction at TRISB : 7 alias pin_P1D_direction is pin_B7_direction -- var volatile bit TRISB_TRISB6 at TRISB : 6 var volatile bit pin_B6_direction at TRISB : 6 alias pin_P1C_direction is pin_B6_direction -- var volatile bit TRISB_TRISB5 at TRISB : 5 var volatile bit pin_B5_direction at TRISB : 5 alias pin_P1B_direction is pin_B5_direction -- var volatile bit TRISB_TRISB4 at TRISB : 4 var volatile bit pin_B4_direction at TRISB : 4 alias pin_ECCPAS0_direction is pin_B4_direction -- var volatile bit TRISB_TRISB3 at TRISB : 3 var volatile bit pin_B3_direction at TRISB : 3 alias pin_CCP1_direction is pin_B3_direction alias pin_P1A_direction is pin_B3_direction -- var volatile bit TRISB_TRISB2 at TRISB : 2 var volatile bit pin_B2_direction at TRISB : 2 alias pin_T1OSI_direction is pin_B2_direction -- var volatile bit TRISB_TRISB1 at TRISB : 1 var volatile bit pin_B1_direction at TRISB : 1 alias pin_T1OSO_direction is pin_B1_direction alias pin_T1CKI_direction is pin_B1_direction -- var volatile bit TRISB_TRISB0 at TRISB : 0 var volatile bit pin_B0_direction at TRISB : 0 alias pin_ECCPAS2_direction is pin_B0_direction -- -- ------------------------------------------------ var volatile byte PIE1 at { 0x8C } var volatile bit PIE1_ADIE at PIE1 : 6 var volatile bit PIE1_CCP1IE at PIE1 : 2 var volatile bit PIE1_TMR2IE at PIE1 : 1 var volatile bit PIE1_TMR1IE at PIE1 : 0 -- ------------------------------------------------ var volatile byte PCON at { 0x8E } var volatile bit PCON_NPOR at PCON : 1 var volatile bit PCON_NBOR at PCON : 0 -- ------------------------------------------------ var volatile byte PR2 at { 0x92 } -- ------------------------------------------------ var volatile byte ADCON1 at { 0x9F } var volatile bit*3 ADCON1_PCFG at ADCON1 : 0 -- -- =================================================== -- -- Special (device specific) constants and procedures -- const ADC_GROUP = ADC_V1 const byte ADC_NTOTAL_CHANNEL = 4 -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - -- Disable ADC module procedure adc_off() is pragma inline ADCON0 = 0b0000_0000 -- disable ADC ADCON1 = 0b0000_0111 -- digital I/O end procedure -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - -- Switch analog ports to digital mode (if analog module present). procedure enable_digital_io() is pragma inline adc_off() end procedure -- -- ================================================== -- -- Symbolic Fuse definitions -- ------------------------- -- -- CONFIG (0x2007) -- pragma fuse_def OSC 0x3 { -- oscillator RC_CLKOUT = 0x3 -- rc HS = 0x2 -- hs XT = 0x1 -- xt LP = 0x0 -- lp } pragma fuse_def WDT 0x4 { -- watchdog timer ENABLED = 0x4 -- on DISABLED = 0x0 -- off } pragma fuse_def PWRTE 0x8 { -- power up timer DISABLED = 0x8 -- off ENABLED = 0x0 -- on } pragma fuse_def BROWNOUT 0x40 { -- brown out detect ENABLED = 0x40 -- on DISABLED = 0x0 -- off } pragma fuse_def VOLTAGE 0x80 { -- brown out voltage V40 = 0x80 -- vbor set to 4.0v V25 = 0x0 -- vbor set to 2.5v } pragma fuse_def CP 0x2000 { -- code protect DISABLED = 0x2000 -- off ENABLED = 0x0 -- all } --