-- =================================================== -- Title: JalV2 device include file for PIC 12F519 -- -- 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 pic12f519, 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/pic12f519.dev -- - x:/mplab880/mpasm suite/lkr/12f519_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[] = "12F519" const byte DATASHEET[] = "41319B" const byte PGMSPEC[] = "41316C" -- -- 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_12 -- (banks=2) pragma target chip 12f519 pragma target bank 0x0020 pragma target page 0x0200 pragma stack 2 pragma code 1024 -- (words) pragma eeprom 0x400,64 pragma ID 0x440,4 pragma data 0x10-0x1F,0x30-0x3F pragma shared 0x7-0xF -- var volatile byte _pic_accum shared at 0x0E -- (compiler) var volatile byte _pic_isr_w shared at 0x0F -- (compiler) -- const word _FUSES_CT = 1 const word _FUSE_BASE = 0xFFF const word _FUSES = 0b_0000_1111_1111_1111 -- -- ------------------------------------------------ var volatile byte INDF at { 0x0,0x20 } var volatile byte _ind at { 0x0,0x20 } -- (compiler) -- ------------------------------------------------ var volatile byte TMR0 at { 0x1 } -- ------------------------------------------------ var volatile byte PCL at { 0x2,0x22 } var volatile byte _pcl at { 0x2,0x22 } -- (compiler) -- ------------------------------------------------ var volatile byte STATUS at { 0x3,0x23 } var volatile bit STATUS_RBWUF at STATUS : 7 var volatile bit STATUS_PA0 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,0x23 } -- (compiler) const byte _rbwuf = 7 -- (compiler) const byte _pa0 = 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,0x24 } var volatile byte _fsr at { 0x4,0x24 } -- (compiler) -- ------------------------------------------------ var volatile byte OSCCAL at { 0x5 } var volatile bit*7 OSCCAL_CAL at OSCCAL : 1 -- ------------------------------------------------ var volatile byte _GPIO at { 0x6 } alias _PORTA is _GPIO -- 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 GPIO_GP5 at _GPIO : 5 var volatile bit pin_A5 at _GPIO : 5 alias pin_GP5 is pin_A5 alias pin_OSC1 is pin_A5 alias pin_CLKIN is pin_A5 -- procedure pin_A5'put(bit in x at _PORTA_shadow : 5) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit GPIO_GP4 at _GPIO : 4 var volatile bit pin_A4 at _GPIO : 4 alias pin_GP4 is pin_A4 alias pin_OSC2 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 GPIO_GP3 at _GPIO : 3 var volatile bit pin_A3 at _GPIO : 3 alias pin_GP3 is pin_A3 alias pin_MCLR is pin_A3 alias pin_VPP is pin_A3 -- procedure pin_A3'put(bit in x at _PORTA_shadow : 3) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit GPIO_GP2 at _GPIO : 2 var volatile bit pin_A2 at _GPIO : 2 alias pin_GP2 is pin_A2 alias pin_T0CKI is pin_A2 -- procedure pin_A2'put(bit in x at _PORTA_shadow : 2) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit GPIO_GP1 at _GPIO : 1 var volatile bit pin_A1 at _GPIO : 1 alias pin_GP1 is pin_A1 alias pin_ICSPCLK is pin_A1 -- procedure pin_A1'put(bit in x at _PORTA_shadow : 1) is pragma inline _PORTA = _PORTA_shadow end procedure -- var volatile bit GPIO_GP0 at _GPIO : 0 var volatile bit pin_A0 at _GPIO : 0 alias pin_GP0 is pin_A0 alias pin_ICSPDAT is pin_A0 -- procedure pin_A0'put(bit in x at _PORTA_shadow : 0) is pragma inline _PORTA = _PORTA_shadow end procedure -- -- ------------------------------------------------ var volatile byte EECON at { 0x21 } var volatile bit EECON_FREE at EECON : 4 var volatile bit EECON_WRERR at EECON : 3 var volatile bit EECON_WREN at EECON : 2 var volatile bit EECON_WR at EECON : 1 var volatile bit EECON_RD at EECON : 0 -- ------------------------------------------------ var volatile byte EEDATA at { 0x25 } -- ------------------------------------------------ var volatile byte EEADR at { 0x26 } -- ------------------------------------------------ var byte _TRISA_shadow = 0b1111_1111 -- default all input -- procedure PORTA_direction'put(byte in x at _TRISA_shadow) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure -- procedure PORTA_low_direction'put(byte in x) is pragma inline _TRISA_shadow = (_TRISA_shadow & 0xF0) | (x & 0x0F) asm movf _TRISA_shadow,W asm tris 6 end procedure -- procedure PORTA_high_direction'put(byte in x) is pragma inline _TRISA_shadow = (_TRISA_shadow & 0x0F) | (x << 4) asm movf _TRISA_shadow,W asm tris 6 end procedure -- procedure pin_A5_direction'put(bit in x at _TRISA_shadow : 5) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP5_direction is pin_A5_direction alias pin_OSC1_direction is pin_A5_direction alias pin_CLKIN_direction is pin_A5_direction -- procedure pin_A4_direction'put(bit in x at _TRISA_shadow : 4) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP4_direction is pin_A4_direction alias pin_OSC2_direction is pin_A4_direction -- procedure pin_A3_direction'put(bit in x at _TRISA_shadow : 3) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP3_direction is pin_A3_direction alias pin_MCLR_direction is pin_A3_direction alias pin_VPP_direction is pin_A3_direction -- procedure pin_A2_direction'put(bit in x at _TRISA_shadow : 2) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP2_direction is pin_A2_direction alias pin_T0CKI_direction is pin_A2_direction -- procedure pin_A1_direction'put(bit in x at _TRISA_shadow : 1) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP1_direction is pin_A1_direction alias pin_ICSPCLK_direction is pin_A1_direction -- procedure pin_A0_direction'put(bit in x at _TRISA_shadow : 0) is pragma inline asm movf _TRISA_shadow,W asm tris 6 end procedure alias pin_GP0_direction is pin_A0_direction alias pin_ICSPDAT_direction is pin_A0_direction -- -- ------------------------------------------------ var byte _OPTION_REG_shadow = 0b1111_1111 -- default all set -- procedure OPTION_REG'put(byte in x at _OPTION_REG_shadow) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure -- procedure OPTION_REG_NRBWU'put(bit in x at _OPTION_REG_shadow : 7) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure -- procedure OPTION_REG_NRBPU'put(bit in x at _OPTION_REG_shadow : 6) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure -- procedure OPTION_REG_T0CS'put(bit in x at _OPTION_REG_shadow : 5) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure alias T0CON_T0CS is OPTION_REG_T0CS -- procedure OPTION_REG_T0SE'put(bit in x at _OPTION_REG_shadow : 4) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure alias T0CON_T0SE is OPTION_REG_T0SE -- procedure OPTION_REG_PSA'put(bit in x at _OPTION_REG_shadow : 3) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure alias T0CON_PSA is OPTION_REG_PSA -- procedure OPTION_REG_PS'put(bit*3 in x at _OPTION_REG_shadow : 0) is pragma inline asm movf _OPTION_REG_shadow,0 asm option end procedure alias T0CON_T0PS is OPTION_REG_PS -- -- =================================================== -- -- 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 OPTION_REG_T0CS = OFF -- T0CKI pin input + output end procedure -- -- ================================================== -- -- Symbolic Fuse definitions -- ------------------------- -- -- CONFIG (0xFFF) -- pragma fuse_def OSC 0x3 { -- oscillator selection bits LP = 0x0 -- lp osc with 18 ms drt XT = 0x1 -- xt osc with 18 ms drt INTOSC_NOCLKOUT = 0x2 -- intrc with 1 ms drt RC_NOCLKOUT = 0x3 -- extrc with 1 ms drt } pragma fuse_def WDT 0x4 { -- watchdog timer enable bit ENABLED = 0x4 -- enabled DISABLED = 0x0 -- disabled } pragma fuse_def CP 0x8 { -- code protection bit DISABLED = 0x8 -- disabled ENABLED = 0x0 -- enabled } pragma fuse_def MCLR 0x10 { -- master clear enable bit EXTERNAL = 0x10 -- enabled INTERNAL = 0x0 -- disabled } pragma fuse_def IOSCFS 0x20 { -- internal oscillator frequency select bit F8MHZ = 0x20 -- 8 mhz intosc speed F4MHZ = 0x0 -- 4 mhz intosc speed } pragma fuse_def CPD 0x40 { -- code protection bit - flash data memory DISABLED = 0x40 -- disabled ENABLED = 0x0 -- enabled } --