-- =================================================== -- Title: JalV2 device include file for PIC 16F83 -- -- Author: Rob Hamerling, Copyright (c) 2008..2011, all rights reserved. -- -- Adapted-by: -- -- Revision: $Revision: 2828 $ -- -- Compiler: 2.4o -- -- 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 pic16f83, 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:/mplab880/mplab ide/device/pic16f83.dev -- - x:/mplab880/mpasm suite/lkr/16f83_g.lkr -- -- Notes: -- - Created with Dev2Jal Rexx script version 0.1.24 -- - File creation date/time: 9 Nov 2011 11:12 -- -- =================================================== -- const word DEVICE_ID = 0x0000 const byte PICTYPE[] = "16F83" const byte DATASHEET[] = "30430C" const byte PGMSPEC[] = "30262E" -- -- Vdd Range: 2.500-6.000 Nominal: 5.000 -- Vpp Range: 12.000-14.000 Default: 13.000 -- -- --------------------------------------------------- -- include chipdef_jallib -- common constants -- pragma target cpu PIC_14 -- (banks=2) pragma target chip 16f83 pragma target bank 0x0080 pragma target page 0x0800 pragma stack 8 pragma code 512 -- (words) pragma eeprom 0x2100,64 pragma ID 0x2000,4 pragma data 0x0C-0x2D pragma shared 0x2E-0x2F -- var volatile byte _pic_accum shared at 0x2E -- (compiler) var volatile byte _pic_isr_w shared at 0x2F -- (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 at _PORTA var byte _PORTA_shadow -- procedure PORTA'put(byte in x at _PORTA_shadow) is pragma inline _PORTA = _PORTA_shadow end procedure -- procedure PORTA_low'put(byte in x) is pragma inline _PORTA_shadow = (_PORTA_shadow & 0xF0) | (x & 0x0F) _PORTA = _PORTA_shadow 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 = _PORTA_shadow 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 = _PORTA_shadow end procedure -- var volatile bit PORTA_RA3 at _PORTA : 3 var volatile bit pin_A3 at _PORTA : 3 -- procedure pin_A3'put(bit in x at _PORTA_shadow : 3) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit PORTA_RA2 at _PORTA : 2 var volatile bit pin_A2 at _PORTA : 2 -- procedure pin_A2'put(bit in x at _PORTA_shadow : 2) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit PORTA_RA1 at _PORTA : 1 var volatile bit pin_A1 at _PORTA : 1 -- procedure pin_A1'put(bit in x at _PORTA_shadow : 1) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit PORTA_RA0 at _PORTA : 0 var volatile bit pin_A0 at _PORTA : 0 -- procedure pin_A0'put(bit in x at _PORTA_shadow : 0) is pragma inline _PORTA = _PORTA_shadow end procedure -- -- ------------------------------------------------ var volatile byte _PORTB at { 0x6 } -- var byte PORTB at _PORTB var byte _PORTB_shadow -- procedure PORTB'put(byte in x at _PORTB_shadow) is pragma inline _PORTB = _PORTB_shadow end procedure -- procedure PORTB_low'put(byte in x) is pragma inline _PORTB_shadow = (_PORTB_shadow & 0xF0) | (x & 0x0F) _PORTB = _PORTB_shadow 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 = _PORTB_shadow 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 -- procedure pin_B7'put(bit in x at _PORTB_shadow : 7) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB6 at _PORTB : 6 var volatile bit pin_B6 at _PORTB : 6 -- procedure pin_B6'put(bit in x at _PORTB_shadow : 6) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB5 at _PORTB : 5 var volatile bit pin_B5 at _PORTB : 5 -- procedure pin_B5'put(bit in x at _PORTB_shadow : 5) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB4 at _PORTB : 4 var volatile bit pin_B4 at _PORTB : 4 -- procedure pin_B4'put(bit in x at _PORTB_shadow : 4) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB3 at _PORTB : 3 var volatile bit pin_B3 at _PORTB : 3 -- procedure pin_B3'put(bit in x at _PORTB_shadow : 3) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB2 at _PORTB : 2 var volatile bit pin_B2 at _PORTB : 2 -- procedure pin_B2'put(bit in x at _PORTB_shadow : 2) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB1 at _PORTB : 1 var volatile bit pin_B1 at _PORTB : 1 -- procedure pin_B1'put(bit in x at _PORTB_shadow : 1) is pragma inline _PORTB = _PORTB_shadow end procedure -- var volatile bit PORTB_RB0 at _PORTB : 0 var volatile bit pin_B0 at _PORTB : 0 alias pin_INT is pin_B0 -- procedure pin_B0'put(bit in x at _PORTB_shadow : 0) is pragma inline _PORTB = _PORTB_shadow end procedure -- -- ------------------------------------------------ var volatile byte EEDATA at { 0x8 } -- ------------------------------------------------ var volatile byte EEADR at { 0x9 } -- ------------------------------------------------ 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_EEIE at INTCON : 6 var volatile bit INTCON_T0IE at INTCON : 5 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_T0IF at INTCON : 2 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 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 -- var volatile bit TRISA_TRISA2 at TRISA : 2 var volatile bit pin_A2_direction at TRISA : 2 -- var volatile bit TRISA_TRISA1 at TRISA : 1 var volatile bit pin_A1_direction at TRISA : 1 -- var volatile bit TRISA_TRISA0 at TRISA : 0 var volatile bit pin_A0_direction at TRISA : 0 -- -- ------------------------------------------------ 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 -- var volatile bit TRISB_TRISB6 at TRISB : 6 var volatile bit pin_B6_direction at TRISB : 6 -- var volatile bit TRISB_TRISB5 at TRISB : 5 var volatile bit pin_B5_direction at TRISB : 5 -- var volatile bit TRISB_TRISB4 at TRISB : 4 var volatile bit pin_B4_direction at TRISB : 4 -- var volatile bit TRISB_TRISB3 at TRISB : 3 var volatile bit pin_B3_direction at TRISB : 3 -- var volatile bit TRISB_TRISB2 at TRISB : 2 var volatile bit pin_B2_direction at TRISB : 2 -- var volatile bit TRISB_TRISB1 at TRISB : 1 var volatile bit pin_B1_direction at TRISB : 1 -- var volatile bit TRISB_TRISB0 at TRISB : 0 var volatile bit pin_B0_direction at TRISB : 0 alias pin_INT_direction is pin_B0_direction -- -- ------------------------------------------------ var volatile byte EECON1 at { 0x88 } var volatile bit EECON1_EEIF at EECON1 : 4 var volatile bit EECON1_WRERR at EECON1 : 3 var volatile bit EECON1_WREN at EECON1 : 2 var volatile bit EECON1_WR at EECON1 : 1 var volatile bit EECON1_RD at EECON1 : 0 -- ------------------------------------------------ var volatile byte EECON2 at { 0x89 } -- -- =================================================== -- -- Special (device specific) constants and procedures -- const ADC_GROUP = 0 -- no ADC module present const byte ADC_NTOTAL_CHANNEL = 0 const byte ADC_ADCS_BITCOUNT = 0 -- const PPS_GROUP = PPS_0 -- no Peripheral Pin Selection -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - -- Switch analog ports to digital mode (if analog module present). procedure enable_digital_io() is pragma inline end procedure -- -- ================================================== -- -- Symbolic Fuse definitions -- ------------------------- -- -- CONFIG (0x2007) -- pragma fuse_def OSC 0x3 { -- oscillator selection bits RC_NOCLKOUT = 0x3 -- rc oscillator HS = 0x2 -- hs oscillator XT = 0x1 -- xt oscillator LP = 0x0 -- lp oscillator } pragma fuse_def WDT 0x4 { -- watchdog timer ENABLED = 0x4 -- enabled DISABLED = 0x0 -- disabled } pragma fuse_def PWRTE 0x8 { -- power-up timer enable bit DISABLED = 0x8 -- disabled ENABLED = 0x0 -- enabled } pragma fuse_def CP 0x3FF0 { -- code protection bit DISABLED = 0x3FF0 -- disabled ENABLED = 0x0 -- enabled } --