Mercurial > public > hwos_code
changeset 644:1e695355dfc4
Merge
author | heinrichsweikamp |
---|---|
date | Mon, 24 May 2021 18:41:51 +0200 |
parents | 7d8a4c60ec1a (diff) 1212d39c9f6f (current diff) |
children | 070528a88715 357341239438 |
files | src/configuration.inc src/option_table.asm src/p2_deco.c |
diffstat | 25 files changed, 4340 insertions(+), 175 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/P18F87K22.INC Mon May 24 18:41:51 2021 +0200 @@ -0,0 +1,2983 @@ + LIST + +;========================================================================== +; MPASM PIC18F87K22 processor include +; +; (c) Copyright 1999-2012 Microchip Technology, All rights reserved +;========================================================================== + + NOLIST + +;========================================================================== +; This header file defines configurations, registers, and other useful +; bits of information for the PIC18F87K22 microcontroller. These names +; are taken to match the data sheets as closely as possible. +; +; Note that the processor must be selected before this file is included. +; The processor may be selected the following ways: +; +; 1. Command line switch: +; C:\MPASM MYFILE.ASM /PIC18F87K22 +; 2. LIST directive in the source file +; LIST P=PIC18F87K22 +; 3. Processor Type entry in the MPASM full-screen interface +; 4. Setting the processor in the MPLAB Project Dialog +;========================================================================== + +;========================================================================== +; +; Verify Processor +; +;========================================================================== + IFNDEF __18F87K22 + MESSG "Processor-header file mismatch. Verify selected processor." + ENDIF + +;========================================================================== +; 18xxxx Family EQUates +;========================================================================== +FSR0 EQU 0 +FSR1 EQU 1 +FSR2 EQU 2 + +FAST EQU 1 + +W EQU 0 +A EQU 0 +ACCESS EQU 0 +BANKED EQU 1 +;========================================================================== + +;========================================================================== +; 16Cxxx/17Cxxx Substitutions +;========================================================================== + #define DDRA TRISA ; PIC17Cxxx SFR substitution + #define DDRB TRISB ; PIC17Cxxx SFR substitution + #define DDRC TRISC ; PIC17Cxxx SFR substitution + #define DDRD TRISD ; PIC17Cxxx SFR substitution + #define DDRE TRISE ; PIC17Cxxx SFR substitution + +;========================================================================== +; +; Register Definitions +; +;========================================================================== + +;----- Register Files ----------------------------------------------------- +PMD3 EQU H'0F16' +PMD2 EQU H'0F17' +PMD1 EQU H'0F18' +PMD0 EQU H'0F19' +PSTR3CON EQU H'0F1A' +PSTR2CON EQU H'0F1B' +TXREG2 EQU H'0F1C' +RCREG2 EQU H'0F1D' +SPBRG2 EQU H'0F1E' +SPBRGH2 EQU H'0F1F' +BAUDCON2 EQU H'0F20' +TXSTA2 EQU H'0F21' +RCSTA2 EQU H'0F22' +ANCON2 EQU H'0F23' +ANCON1 EQU H'0F24' +ANCON0 EQU H'0F25' +MEMCON EQU H'0F26' +ODCON3 EQU H'0F27' +ODCON2 EQU H'0F28' +ODCON1 EQU H'0F29' +REFOCON EQU H'0F2A' +CCPTMRS2 EQU H'0F2B' +CCPTMRS1 EQU H'0F2C' +CCPTMRS0 EQU H'0F2D' +CM3CON EQU H'0F2E' +CM3CON1 EQU H'0F2E' +CM2CON EQU H'0F2F' +CM2CON1 EQU H'0F2F' +T12CON EQU H'0F30' +PR12 EQU H'0F31' +TMR12 EQU H'0F32' +T10CON EQU H'0F33' +PR10 EQU H'0F34' +TMR10 EQU H'0F35' +T8CON EQU H'0F36' +PR8 EQU H'0F37' +TMR8 EQU H'0F38' +T6CON EQU H'0F39' +PR6 EQU H'0F3A' +TMR6 EQU H'0F3B' +T7GCON EQU H'0F3C' +T7CON EQU H'0F3D' +TMR7 EQU H'0F3E' +TMR7L EQU H'0F3E' +TMR7H EQU H'0F3F' +CCP10CON EQU H'0F40' +CCPR10 EQU H'0F41' +CCPR10L EQU H'0F41' +CCPR10H EQU H'0F42' +CCP9CON EQU H'0F43' +CCPR9 EQU H'0F44' +CCPR9L EQU H'0F44' +CCPR9H EQU H'0F45' +CCP8CON EQU H'0F46' +CCPR8 EQU H'0F47' +CCPR8L EQU H'0F47' +CCPR8H EQU H'0F48' +CCP3CON EQU H'0F49' +CCPR3 EQU H'0F4A' +CCPR3L EQU H'0F4A' +CCPR3H EQU H'0F4B' +ECCP3DEL EQU H'0F4C' +ECCP3AS EQU H'0F4D' +CCP2CON EQU H'0F4E' +ECCP2CON EQU H'0F4E' +CCPR2 EQU H'0F4F' +CCPR2L EQU H'0F4F' +CCPR2H EQU H'0F50' +ECCP2DEL EQU H'0F51' +PWM2CON EQU H'0F51' +ECCP2AS EQU H'0F52' +PADCFG1 EQU H'0F53' +CM1CON EQU H'0F54' +CM1CON1 EQU H'0F54' +CTMUICON EQU H'0F55' +CTMUCONL EQU H'0F56' +CTMUCONH EQU H'0F57' +ALRMVAL EQU H'0F58' +ALRMVALL EQU H'0F58' +ALRMVALH EQU H'0F59' +ALRMRPT EQU H'0F5A' +ALRMCFG EQU H'0F5B' +RTCVAL EQU H'0F5C' +RTCVALL EQU H'0F5C' +RTCVALH EQU H'0F5D' +RTCCAL EQU H'0F5E' +RTCCFG EQU H'0F5F' +PIE6 EQU H'0F60' +EEDATA EQU H'0F61' +EEADR EQU H'0F62' +EEADRH EQU H'0F63' +OSCCON2 EQU H'0F64' +BAUDCON EQU H'0F65' +BAUDCON1 EQU H'0F65' +BAUDCTL EQU H'0F65' +SSP2CON2 EQU H'0F66' +SSP2CON1 EQU H'0F67' +SSP2STAT EQU H'0F68' +SSP2ADD EQU H'0F69' +SSP2MSK EQU H'0F69' +SSP2BUF EQU H'0F6A' +T4CON EQU H'0F6B' +PR4 EQU H'0F6C' +TMR4 EQU H'0F6D' +CCP7CON EQU H'0F6E' +CCPR7 EQU H'0F6F' +CCPR7L EQU H'0F6F' +CCPR7H EQU H'0F70' +CCP6CON EQU H'0F71' +CCPR6 EQU H'0F72' +CCPR6L EQU H'0F72' +CCPR6H EQU H'0F73' +CCP5CON EQU H'0F74' +CCPR5 EQU H'0F75' +CCPR5L EQU H'0F75' +CCPR5H EQU H'0F76' +CCP4CON EQU H'0F77' +CCPR4 EQU H'0F78' +CCPR4L EQU H'0F78' +CCPR4H EQU H'0F79' +T5GCON EQU H'0F7A' +T5CON EQU H'0F7B' +TMR5 EQU H'0F7C' +TMR5L EQU H'0F7C' +TMR5H EQU H'0F7D' +EECON2 EQU H'0F7E' +EECON1 EQU H'0F7F' +PORTA EQU H'0F80' +PORTB EQU H'0F81' +PORTC EQU H'0F82' +PORTD EQU H'0F83' +PORTE EQU H'0F84' +PORTF EQU H'0F85' +PORTG EQU H'0F86' +PORTH EQU H'0F87' +PORTJ EQU H'0F88' +LATA EQU H'0F89' +LATB EQU H'0F8A' +LATC EQU H'0F8B' +LATD EQU H'0F8C' +LATE EQU H'0F8D' +LATF EQU H'0F8E' +LATG EQU H'0F8F' +LATH EQU H'0F90' +LATJ EQU H'0F91' +TRISA EQU H'0F92' +TRISB EQU H'0F93' +TRISC EQU H'0F94' +TRISD EQU H'0F95' +TRISE EQU H'0F96' +TRISF EQU H'0F97' +TRISG EQU H'0F98' +TRISH EQU H'0F99' +TRISJ EQU H'0F9A' +OSCTUNE EQU H'0F9B' +PSTR1CON EQU H'0F9C' +PIE1 EQU H'0F9D' +PIR1 EQU H'0F9E' +IPR1 EQU H'0F9F' +PIE2 EQU H'0FA0' +PIR2 EQU H'0FA1' +IPR2 EQU H'0FA2' +PIE3 EQU H'0FA3' +PIR3 EQU H'0FA4' +IPR3 EQU H'0FA5' +PIR6 EQU H'0FA6' +PSPCON EQU H'0FA7' +HLVDCON EQU H'0FA8' +IPR6 EQU H'0FA9' +T1GCON EQU H'0FAA' +RCSTA EQU H'0FAB' +RCSTA1 EQU H'0FAB' +TXSTA EQU H'0FAC' +TXSTA1 EQU H'0FAC' +TXREG EQU H'0FAD' +TXREG1 EQU H'0FAD' +RCREG EQU H'0FAE' +RCREG1 EQU H'0FAE' +SPBRG EQU H'0FAF' +SPBRG1 EQU H'0FAF' +T3GCON EQU H'0FB0' +T3CON EQU H'0FB1' +TMR3 EQU H'0FB2' +TMR3L EQU H'0FB2' +TMR3H EQU H'0FB3' +CMSTAT EQU H'0FB4' +CMSTATUS EQU H'0FB4' +CVRCON EQU H'0FB5' +PIE4 EQU H'0FB6' +PIR4 EQU H'0FB7' +IPR4 EQU H'0FB8' +PIE5 EQU H'0FB9' +PIR5 EQU H'0FBA' +CCP1CON EQU H'0FBB' +ECCP1CON EQU H'0FBB' +CCPR1 EQU H'0FBC' +CCPR1L EQU H'0FBC' +CCPR1H EQU H'0FBD' +ECCP1DEL EQU H'0FBE' +PWM1CON EQU H'0FBE' +ECCP1AS EQU H'0FBF' +ADCON2 EQU H'0FC0' +ADCON1 EQU H'0FC1' +ADCON0 EQU H'0FC2' +ADRES EQU H'0FC3' +ADRESL EQU H'0FC3' +ADRESH EQU H'0FC4' +SSP1CON2 EQU H'0FC5' +SSPCON2 EQU H'0FC5' +SSP1CON1 EQU H'0FC6' +SSPCON1 EQU H'0FC6' +SSP1STAT EQU H'0FC7' +SSPSTAT EQU H'0FC7' +SSP1ADD EQU H'0FC8' +SSP1MSK EQU H'0FC8' +SSPADD EQU H'0FC8' +SSP1BUF EQU H'0FC9' +SSPBUF EQU H'0FC9' +T2CON EQU H'0FCA' +PR2 EQU H'0FCB' +TMR2 EQU H'0FCC' +T1CON EQU H'0FCD' +TMR1 EQU H'0FCE' +TMR1L EQU H'0FCE' +TMR1H EQU H'0FCF' +RCON EQU H'0FD0' +WDTCON EQU H'0FD1' +IPR5 EQU H'0FD2' +OSCCON EQU H'0FD3' +SPBRGH1 EQU H'0FD4' +T0CON EQU H'0FD5' +TMR0 EQU H'0FD6' +TMR0L EQU H'0FD6' +TMR0H EQU H'0FD7' +STATUS EQU H'0FD8' +FSR2L EQU H'0FD9' +FSR2H EQU H'0FDA' +PLUSW2 EQU H'0FDB' +PREINC2 EQU H'0FDC' +POSTDEC2 EQU H'0FDD' +POSTINC2 EQU H'0FDE' +INDF2 EQU H'0FDF' +BSR EQU H'0FE0' +FSR1L EQU H'0FE1' +FSR1H EQU H'0FE2' +PLUSW1 EQU H'0FE3' +PREINC1 EQU H'0FE4' +POSTDEC1 EQU H'0FE5' +POSTINC1 EQU H'0FE6' +INDF1 EQU H'0FE7' +WREG EQU H'0FE8' +FSR0L EQU H'0FE9' +FSR0H EQU H'0FEA' +PLUSW0 EQU H'0FEB' +PREINC0 EQU H'0FEC' +POSTDEC0 EQU H'0FED' +POSTINC0 EQU H'0FEE' +INDF0 EQU H'0FEF' +INTCON3 EQU H'0FF0' +INTCON2 EQU H'0FF1' +INTCON EQU H'0FF2' +PROD EQU H'0FF3' +PRODL EQU H'0FF3' +PRODH EQU H'0FF4' +TABLAT EQU H'0FF5' +TBLPTR EQU H'0FF6' +TBLPTRL EQU H'0FF6' +TBLPTRH EQU H'0FF7' +TBLPTRU EQU H'0FF8' +PC EQU H'0FF9' +PCL EQU H'0FF9' +PCLATH EQU H'0FFA' +PCLATU EQU H'0FFB' +STKPTR EQU H'0FFC' +TOS EQU H'0FFD' +TOSL EQU H'0FFD' +TOSH EQU H'0FFE' +TOSU EQU H'0FFF' + +;----- PMD3 Bits ----------------------------------------------------- +TMR12MD EQU H'0000' +CCP4MD EQU H'0001' +CCP5MD EQU H'0002' +CCP6MD EQU H'0003' +CCP7MD EQU H'0004' +CCP8MD EQU H'0005' +CCP9MD EQU H'0006' +CCP10MD EQU H'0007' + + +;----- PMD2 Bits ----------------------------------------------------- +CMP1MD EQU H'0000' +CMP2MD EQU H'0001' +CMP3MD EQU H'0002' +TMR5MD EQU H'0003' +TMR6MD EQU H'0004' +TMR7MD EQU H'0005' +TMR8MD EQU H'0006' +TMR10MD EQU H'0007' + + +;----- PMD1 Bits ----------------------------------------------------- +EMBMD EQU H'0000' +TMR1MD EQU H'0001' +TMR2MD EQU H'0002' +TMR3MD EQU H'0003' +TMR4MD EQU H'0004' +RTCCMD EQU H'0005' +CTMUMD EQU H'0006' +PSPMD EQU H'0007' + + +;----- PMD0 Bits ----------------------------------------------------- +ADCMD EQU H'0000' +SSP1MD EQU H'0001' +SSP2MD EQU H'0002' +UART1MD EQU H'0003' +UART2MD EQU H'0004' +CCP1MD EQU H'0005' +CCP2MD EQU H'0006' +CCP3MD EQU H'0007' + + +;----- PSTR3CON Bits ----------------------------------------------------- +STRA EQU H'0000' +STRB EQU H'0001' +STRC EQU H'0002' +STRD EQU H'0003' +STRSYNC EQU H'0004' + +CMPL0 EQU H'0006' +CMPL1 EQU H'0007' + + +;----- PSTR2CON Bits ----------------------------------------------------- +STRA EQU H'0000' +STRB EQU H'0001' +STRC EQU H'0002' +STRD EQU H'0003' +STRSYNC EQU H'0004' + +CMPL0 EQU H'0006' +CMPL1 EQU H'0007' + + +;----- BAUDCON2 Bits ----------------------------------------------------- +ABDEN EQU H'0000' +WUE EQU H'0001' +BRG16 EQU H'0003' +TXCKP EQU H'0004' +RXDTP EQU H'0005' +RCIDL EQU H'0006' +ABDOVF EQU H'0007' + + +;----- TXSTA2 Bits ----------------------------------------------------- +TX9D EQU H'0000' +TRMT EQU H'0001' +BRGH EQU H'0002' +SENDB EQU H'0003' +SYNC EQU H'0004' +TXEN EQU H'0005' +TX9 EQU H'0006' +CSRC EQU H'0007' + +TX9D2 EQU H'0000' +TRMT2 EQU H'0001' +BRGH2 EQU H'0002' +SENDB2 EQU H'0003' +SYNC2 EQU H'0004' +TXEN2 EQU H'0005' +TX92 EQU H'0006' +CSRC2 EQU H'0007' + + +;----- RCSTA2 Bits ----------------------------------------------------- +RX9D EQU H'0000' +OERR EQU H'0001' +FERR EQU H'0002' +ADDEN EQU H'0003' +CREN EQU H'0004' +SREN EQU H'0005' +RX9 EQU H'0006' +SPEN EQU H'0007' + +RX9D2 EQU H'0000' +OERR2 EQU H'0001' +FERR2 EQU H'0002' +ADDEN2 EQU H'0003' +CREN2 EQU H'0004' +SREN2 EQU H'0005' +RX92 EQU H'0006' +SPEN2 EQU H'0007' + + +;----- ANCON2 Bits ----------------------------------------------------- +ANSEL16 EQU H'0000' +ANSEL17 EQU H'0001' +ANSEL18 EQU H'0002' +ANSEL19 EQU H'0003' +ANSEL20 EQU H'0004' +ANSEL21 EQU H'0005' +ANSEL22 EQU H'0006' +ANSEL23 EQU H'0007' + + +;----- ANCON1 Bits ----------------------------------------------------- +ANSEL8 EQU H'0000' +ANSEL9 EQU H'0001' +ANSEL10 EQU H'0002' +ANSEL11 EQU H'0003' +ANSEL12 EQU H'0004' +ANSEL13 EQU H'0005' +ANSEL14 EQU H'0006' +ANSEL15 EQU H'0007' + + +;----- ANCON0 Bits ----------------------------------------------------- +ANSEL0 EQU H'0000' +ANSEL1 EQU H'0001' +ANSEL2 EQU H'0002' +ANSEL3 EQU H'0003' +ANSEL4 EQU H'0004' +ANSEL5 EQU H'0005' +ANSEL6 EQU H'0006' +ANSEL7 EQU H'0007' + + +;----- MEMCON Bits ----------------------------------------------------- +EBDIS EQU H'0007' + +WM0 EQU H'0000' +WM1 EQU H'0001' +WAIT0 EQU H'0004' +WAIT1 EQU H'0005' + + +;----- ODCON3 Bits ----------------------------------------------------- +CTMUDS EQU H'0000' +U1OD EQU H'0006' +U2OD EQU H'0007' + + +;----- ODCON2 Bits ----------------------------------------------------- +CCP3OD EQU H'0000' +CCP4OD EQU H'0001' +CCP5OD EQU H'0002' +CCP6OD EQU H'0003' +CCP7OD EQU H'0004' +CCP8OD EQU H'0005' +CCP9OD EQU H'0006' +CCP10OD EQU H'0007' + + +;----- ODCON1 Bits ----------------------------------------------------- +SPI2OD EQU H'0000' +CCP1OD EQU H'0005' +CCP2OD EQU H'0006' +SPI1OD EQU H'0007' + + +;----- REFOCON Bits ----------------------------------------------------- +ROSEL EQU H'0004' +ROSSLP EQU H'0005' +ROON EQU H'0007' + +RODIV0 EQU H'0000' +RODIV1 EQU H'0001' +RODIV2 EQU H'0002' +RODIV3 EQU H'0003' + + +;----- CCPTMRS2 Bits ----------------------------------------------------- +C9TSEL0 EQU H'0002' +C10TSEL0 EQU H'0004' + +C8TSEL0 EQU H'0000' +C8TSEL1 EQU H'0001' + + +;----- CCPTMRS1 Bits ----------------------------------------------------- +C5TSEL0 EQU H'0002' +C6TSEL0 EQU H'0004' + +C4TSEL0 EQU H'0000' +C4TSEL1 EQU H'0001' +C7TSEL0 EQU H'0006' +C7TSEL1 EQU H'0007' + + +;----- CCPTMRS0 Bits ----------------------------------------------------- +C1TSEL0 EQU H'0000' +C1TSEL1 EQU H'0001' +C1TSEL2 EQU H'0002' +C2TSEL0 EQU H'0003' +C2TSEL1 EQU H'0004' +C2TSEL2 EQU H'0005' +C3TSEL0 EQU H'0006' +C3TSEL1 EQU H'0007' + + +;----- CM3CON Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- CM3CON1 Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- CM2CON Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- CM2CON1 Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- T12CON Bits ----------------------------------------------------- +TMR12ON EQU H'0002' + +T12CKPS0 EQU H'0000' +T12CKPS1 EQU H'0001' +T12OUTPS0 EQU H'0003' +T12OUTPS1 EQU H'0004' +T12OUTPS2 EQU H'0005' +T12OUTPS3 EQU H'0006' + + +;----- T10CON Bits ----------------------------------------------------- +TMR10ON EQU H'0002' + +T10CKPS0 EQU H'0000' +T10CKPS1 EQU H'0001' +T10OUTPS0 EQU H'0003' +T10OUTPS1 EQU H'0004' +T10OUTPS2 EQU H'0005' +T10OUTPS3 EQU H'0006' + + +;----- T8CON Bits ----------------------------------------------------- +TMR8ON EQU H'0002' + +T8CKPS0 EQU H'0000' +T8CKPS1 EQU H'0001' +T8OUTPS0 EQU H'0003' +T8OUTPS1 EQU H'0004' +T8OUTPS2 EQU H'0005' +T8OUTPS3 EQU H'0006' + + +;----- T6CON Bits ----------------------------------------------------- +TMR6ON EQU H'0002' + +T6CKPS0 EQU H'0000' +T6CKPS1 EQU H'0001' +T6OUTPS0 EQU H'0003' +T6OUTPS1 EQU H'0004' +T6OUTPS2 EQU H'0005' +T6OUTPS3 EQU H'0006' + + +;----- T7GCON Bits ----------------------------------------------------- +T7GVAL EQU H'0002' +T7GGO_NOT_T7DONE EQU H'0003' +T7GSPM EQU H'0004' +T7GTM EQU H'0005' +T7GPOL EQU H'0006' +TMR7GE EQU H'0007' + +T7GSS0 EQU H'0000' +T7GSS1 EQU H'0001' +T7GGO EQU H'0003' + +NOT_T7DONE EQU H'0003' + + +;----- T7CON Bits ----------------------------------------------------- +TMR7ON EQU H'0000' +RD16 EQU H'0001' +NOT_T7SYNC EQU H'0002' +SOSCEN EQU H'0003' + +T7CKPS0 EQU H'0004' +T7CKPS1 EQU H'0005' +TMR7CS0 EQU H'0006' +TMR7CS1 EQU H'0007' + + +;----- CCP10CON Bits ----------------------------------------------------- +CCP10M0 EQU H'0000' +CCP10M1 EQU H'0001' +CCP10M2 EQU H'0002' +CCP10M3 EQU H'0003' +DC10B0 EQU H'0004' +DC10B1 EQU H'0005' + +CCP10Y EQU H'0004' +CCP10X EQU H'0005' + + +;----- CCP9CON Bits ----------------------------------------------------- +CCP9M0 EQU H'0000' +CCP9M1 EQU H'0001' +CCP9M2 EQU H'0002' +CCP9M3 EQU H'0003' +DC9B0 EQU H'0004' +DC9B1 EQU H'0005' + +CCP9Y EQU H'0004' +CCP9X EQU H'0005' + + +;----- CCP8CON Bits ----------------------------------------------------- +CCP8M0 EQU H'0000' +CCP8M1 EQU H'0001' +CCP8M2 EQU H'0002' +CCP8M3 EQU H'0003' +DC8B0 EQU H'0004' +DC8B1 EQU H'0005' + +CCP8Y EQU H'0004' +CCP8X EQU H'0005' + + +;----- CCP3CON Bits ----------------------------------------------------- +CCP3M0 EQU H'0000' +CCP3M1 EQU H'0001' +CCP3M2 EQU H'0002' +CCP3M3 EQU H'0003' +DC3B0 EQU H'0004' +DC3B1 EQU H'0005' +P3M0 EQU H'0006' +P3M1 EQU H'0007' + + +;----- ECCP3DEL Bits ----------------------------------------------------- +P3RSEN EQU H'0007' + +P3DC0 EQU H'0000' +P3DC1 EQU H'0001' +P3DC2 EQU H'0002' +P3DC3 EQU H'0003' +P3DC4 EQU H'0004' +P3DC5 EQU H'0005' +P3DC6 EQU H'0006' + + +;----- ECCP3AS Bits ----------------------------------------------------- +ECCP3ASE EQU H'0007' + +PSS3BD0 EQU H'0000' +PSS3BD1 EQU H'0001' +PSS3AC0 EQU H'0002' +PSS3AC1 EQU H'0003' +ECCP3AS0 EQU H'0004' +ECCP3AS1 EQU H'0005' +ECCP3AS2 EQU H'0006' + + +;----- CCP2CON Bits ----------------------------------------------------- +CCP2M0 EQU H'0000' +CCP2M1 EQU H'0001' +CCP2M2 EQU H'0002' +CCP2M3 EQU H'0003' +DC2B0 EQU H'0004' +DC2B1 EQU H'0005' +P2M0 EQU H'0006' +P2M1 EQU H'0007' + +CCP2Y EQU H'0004' +CCP2X EQU H'0005' + + +;----- ECCP2CON Bits ----------------------------------------------------- +CCP2M0 EQU H'0000' +CCP2M1 EQU H'0001' +CCP2M2 EQU H'0002' +CCP2M3 EQU H'0003' +DC2B0 EQU H'0004' +DC2B1 EQU H'0005' +P2M0 EQU H'0006' +P2M1 EQU H'0007' + +CCP2Y EQU H'0004' +CCP2X EQU H'0005' + + +;----- ECCP2DEL Bits ----------------------------------------------------- +P2RSEN EQU H'0007' + +P2DC0 EQU H'0000' +P2DC1 EQU H'0001' +P2DC2 EQU H'0002' +P2DC3 EQU H'0003' +P2DC4 EQU H'0004' +P2DC5 EQU H'0005' +P2DC6 EQU H'0006' + + +;----- PWM2CON Bits ----------------------------------------------------- +P2RSEN EQU H'0007' + +P2DC0 EQU H'0000' +P2DC1 EQU H'0001' +P2DC2 EQU H'0002' +P2DC3 EQU H'0003' +P2DC4 EQU H'0004' +P2DC5 EQU H'0005' +P2DC6 EQU H'0006' + + +;----- ECCP2AS Bits ----------------------------------------------------- +ECCP2ASE EQU H'0007' + +PSS2BD0 EQU H'0000' +PSS2BD1 EQU H'0001' +PSS2AC0 EQU H'0002' +PSS2AC1 EQU H'0003' +ECCP2AS0 EQU H'0004' +ECCP2AS1 EQU H'0005' +ECCP2AS2 EQU H'0006' + + +;----- PADCFG1 Bits ----------------------------------------------------- +RJPU EQU H'0005' +REPU EQU H'0006' +RDPU EQU H'0007' + +RTSECSEL0 EQU H'0001' +RTSECSEL1 EQU H'0002' + + +;----- CM1CON Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- CM1CON1 Bits ----------------------------------------------------- +CREF EQU H'0002' +CPOL EQU H'0005' +COE EQU H'0006' +CON EQU H'0007' + +CCH0 EQU H'0000' +CCH1 EQU H'0001' +EVPOL0 EQU H'0003' +EVPOL1 EQU H'0004' + + +;----- CTMUICON Bits ----------------------------------------------------- +IRNG0 EQU H'0000' +IRNG1 EQU H'0001' +ITRIM0 EQU H'0002' +ITRIM1 EQU H'0003' +ITRIM2 EQU H'0004' +ITRIM3 EQU H'0005' +ITRIM4 EQU H'0006' +ITRIM5 EQU H'0007' + + +;----- CTMUCONL Bits ----------------------------------------------------- +EDG1STAT EQU H'0000' +EDG2STAT EQU H'0001' +EDG1POL EQU H'0004' +EDG2POL EQU H'0007' + +EDG1SEL0 EQU H'0002' +EDG1SEL1 EQU H'0003' +EDG2SEL0 EQU H'0005' +EDG2SEL1 EQU H'0006' + + +;----- CTMUCONH Bits ----------------------------------------------------- +CTTRIG EQU H'0000' +IDISSEN EQU H'0001' +EDGSEQEN EQU H'0002' +EDGEN EQU H'0003' +TGEN EQU H'0004' +CTMUSIDL EQU H'0005' +CTMUEN EQU H'0007' + + +;----- ALRMRPT Bits ----------------------------------------------------- +ARPT0 EQU H'0000' +ARPT1 EQU H'0001' +ARPT2 EQU H'0002' +ARPT3 EQU H'0003' +ARPT4 EQU H'0004' +ARPT5 EQU H'0005' +ARPT6 EQU H'0006' +ARPT7 EQU H'0007' + + +;----- ALRMCFG Bits ----------------------------------------------------- +CHIME EQU H'0006' +ALRMEN EQU H'0007' + +ALRMPTR0 EQU H'0000' +ALRMPTR1 EQU H'0001' +AMASK0 EQU H'0002' +AMASK1 EQU H'0003' +AMASK2 EQU H'0004' +AMASK3 EQU H'0005' + + +;----- RTCCAL Bits ----------------------------------------------------- +CAL0 EQU H'0000' +CAL1 EQU H'0001' +CAL2 EQU H'0002' +CAL3 EQU H'0003' +CAL4 EQU H'0004' +CAL5 EQU H'0005' +CAL6 EQU H'0006' +CAL7 EQU H'0007' + + +;----- RTCCFG Bits ----------------------------------------------------- +RTCOE EQU H'0002' +HALFSEC EQU H'0003' +RTCSYNC EQU H'0004' +RTCWREN EQU H'0005' +RTCEN EQU H'0007' + +RTCPTR0 EQU H'0000' +RTCPTR1 EQU H'0001' + + +;----- PIE6 Bits ----------------------------------------------------- +CMP1IE EQU H'0000' +CMP2IE EQU H'0001' +CMP3IE EQU H'0002' +EEIE EQU H'0004' + + +;----- OSCCON2 Bits ----------------------------------------------------- +MFIOSEL EQU H'0000' +MFIOFS EQU H'0001' +SOSCGO EQU H'0003' +SOSCRUN EQU H'0006' + + +;----- BAUDCON Bits ----------------------------------------------------- +ABDEN EQU H'0000' +WUE EQU H'0001' +BRG16 EQU H'0003' +TXCKP EQU H'0004' +RXDTP EQU H'0005' +RCIDL EQU H'0006' +ABDOVF EQU H'0007' + + +;----- BAUDCON1 Bits ----------------------------------------------------- +ABDEN EQU H'0000' +WUE EQU H'0001' +BRG16 EQU H'0003' +TXCKP EQU H'0004' +RXDTP EQU H'0005' +RCIDL EQU H'0006' +ABDOVF EQU H'0007' + + +;----- BAUDCTL Bits ----------------------------------------------------- +ABDEN EQU H'0000' +WUE EQU H'0001' +BRG16 EQU H'0003' +TXCKP EQU H'0004' +RXDTP EQU H'0005' +RCIDL EQU H'0006' +ABDOVF EQU H'0007' + + +;----- SSP2CON2 Bits ----------------------------------------------------- +SEN EQU H'0000' +RSEN EQU H'0001' +PEN EQU H'0002' +RCEN EQU H'0003' +ACKEN EQU H'0004' +ACKDT EQU H'0005' +ACKSTAT EQU H'0006' +GCEN EQU H'0007' + +ADMSK1 EQU H'0001' +ADMSK2 EQU H'0002' +ADMSK3 EQU H'0003' +ADMSK4 EQU H'0004' +ADMSK5 EQU H'0005' + + +;----- SSP2CON1 Bits ----------------------------------------------------- +CKP EQU H'0004' +SSPEN EQU H'0005' +SSPOV EQU H'0006' +WCOL EQU H'0007' + +SSPM0 EQU H'0000' +SSPM1 EQU H'0001' +SSPM2 EQU H'0002' +SSPM3 EQU H'0003' + + +;----- SSP2STAT Bits ----------------------------------------------------- +BF EQU H'0000' +UA EQU H'0001' +R_NOT_W EQU H'0002' +S EQU H'0003' +P EQU H'0004' +D_NOT_A EQU H'0005' +CKE EQU H'0006' +SMP EQU H'0007' + +R EQU H'0002' +D EQU H'0005' + +R_W EQU H'0002' +D_A EQU H'0005' + +NOT_W EQU H'0002' +NOT_A EQU H'0005' + +NOT_WRITE EQU H'0002' +NOT_ADDRESS EQU H'0005' + +READ_WRITE EQU H'0002' +DATA_ADDRESS EQU H'0005' + +I2C_READ EQU H'0002' +I2C_START EQU H'0003' +I2C_STOP EQU H'0004' +I2C_DAT EQU H'0005' + + +;----- SSP2MSK Bits ----------------------------------------------------- +MSK0 EQU H'0000' +MSK1 EQU H'0001' +MSK2 EQU H'0002' +MSK3 EQU H'0003' +MSK4 EQU H'0004' +MSK5 EQU H'0005' +MSK6 EQU H'0006' +MSK7 EQU H'0007' + + +;----- T4CON Bits ----------------------------------------------------- +TMR4ON EQU H'0002' + +T4CKPS0 EQU H'0000' +T4CKPS1 EQU H'0001' +T4OUTPS0 EQU H'0003' +T4OUTPS1 EQU H'0004' +T4OUTPS2 EQU H'0005' +T4OUTPS3 EQU H'0006' + + +;----- CCP7CON Bits ----------------------------------------------------- +CCP7M0 EQU H'0000' +CCP7M1 EQU H'0001' +CCP7M2 EQU H'0002' +CCP7M3 EQU H'0003' +DC7B0 EQU H'0004' +DC7B1 EQU H'0005' + +CCP7Y EQU H'0004' +CCP7X EQU H'0005' + + +;----- CCP6CON Bits ----------------------------------------------------- +CCP6M0 EQU H'0000' +CCP6M1 EQU H'0001' +CCP6M2 EQU H'0002' +CCP6M3 EQU H'0003' +DC6B0 EQU H'0004' +DC6B1 EQU H'0005' + +CCP6Y EQU H'0004' +CCP6X EQU H'0005' + + +;----- CCP5CON Bits ----------------------------------------------------- +CCP5M0 EQU H'0000' +CCP5M1 EQU H'0001' +CCP5M2 EQU H'0002' +CCP5M3 EQU H'0003' +DC5B0 EQU H'0004' +DC5B1 EQU H'0005' + +CCP5Y EQU H'0004' +CCP5X EQU H'0005' + + +;----- CCP4CON Bits ----------------------------------------------------- +CCP4M0 EQU H'0000' +CCP4M1 EQU H'0001' +CCP4M2 EQU H'0002' +CCP4M3 EQU H'0003' +DC4B0 EQU H'0004' +DC4B1 EQU H'0005' + +CCP4Y EQU H'0004' +CCP4X EQU H'0005' + + +;----- T5GCON Bits ----------------------------------------------------- +T5GVAL EQU H'0002' +T5GGO_NOT_T5DONE EQU H'0003' +T5GSPM EQU H'0004' +T5GTM EQU H'0005' +T5GPOL EQU H'0006' +TMR5GE EQU H'0007' + +T5GSS0 EQU H'0000' +T5GSS1 EQU H'0001' +T5GGO EQU H'0003' + +NOT_T5DONE EQU H'0003' + + +;----- T5CON Bits ----------------------------------------------------- +TMR5ON EQU H'0000' +RD16 EQU H'0001' +NOT_T5SYNC EQU H'0002' +SOSCEN EQU H'0003' + +T5CKPS0 EQU H'0004' +T5CKPS1 EQU H'0005' +TMR5CS0 EQU H'0006' +TMR5CS1 EQU H'0007' + + +;----- EECON1 Bits ----------------------------------------------------- +RD EQU H'0000' +WR EQU H'0001' +WREN EQU H'0002' +WRERR EQU H'0003' +FREE EQU H'0004' +CFGS EQU H'0006' +EEPGD EQU H'0007' + + +;----- PORTA Bits ----------------------------------------------------- +RA0 EQU H'0000' +RA1 EQU H'0001' +RA2 EQU H'0002' +RA3 EQU H'0003' +RA4 EQU H'0004' +RA5 EQU H'0005' +RA6 EQU H'0006' +RA7 EQU H'0007' + +AN0 EQU H'0000' +AN1 EQU H'0001' +AN2 EQU H'0002' +AN3 EQU H'0003' +AN4 EQU H'0005' +OSC2 EQU H'0006' +OSC1 EQU H'0007' + +ULPWU EQU H'0000' +VREF_MINUS EQU H'0002' +VREF_PLUS EQU H'0003' +T0CKI EQU H'0004' +T1CKI EQU H'0005' +CLKO EQU H'0006' +CLKI EQU H'0007' + +T3G EQU H'0005' + +HLVDIN EQU H'0005' + + +;----- PORTB Bits ----------------------------------------------------- +RB0 EQU H'0000' +RB1 EQU H'0001' +RB2 EQU H'0002' +RB3 EQU H'0003' +RB4 EQU H'0004' +RB5 EQU H'0005' +RB6 EQU H'0006' +RB7 EQU H'0007' + +INT0 EQU H'0000' +INT1 EQU H'0001' +INT2 EQU H'0002' +INT3 EQU H'0003' +KBI0 EQU H'0004' +KBI1 EQU H'0005' +KBI2 EQU H'0006' +KBI3 EQU H'0007' + +FLT0 EQU H'0000' +CTED1 EQU H'0002' +CTED2 EQU H'0003' +T3CKI EQU H'0005' + +CCP2_P2A EQU H'0003' +T1G EQU H'0005' + +PGM EQU H'0005' +PGC EQU H'0006' +PGD EQU H'0007' + + +;----- PORTC Bits ----------------------------------------------------- +RC0 EQU H'0000' +RC1 EQU H'0001' +RC2 EQU H'0002' +RC3 EQU H'0003' +RC4 EQU H'0004' +RC5 EQU H'0005' +RC6 EQU H'0006' +RC7 EQU H'0007' + +SOSCO EQU H'0000' +SOSCI EQU H'0001' +SCK1 EQU H'0003' +SDI1 EQU H'0004' +SDO1 EQU H'0005' +TX1 EQU H'0006' +RX1 EQU H'0007' + +SCKLI EQU H'0000' +CCP2_PORTC EQU H'0001' +CCP1 EQU H'0002' +SCL1 EQU H'0003' +SDA1 EQU H'0004' +CK1 EQU H'0006' +DT1 EQU H'0007' + +P2A_PORTC EQU H'0001' +P1A EQU H'0002' + + +;----- PORTD Bits ----------------------------------------------------- +RD0 EQU H'0000' +RD1 EQU H'0001' +RD2 EQU H'0002' +RD3 EQU H'0003' +RD4 EQU H'0004' +RD5 EQU H'0005' +RD6 EQU H'0006' +RD7 EQU H'0007' + +AD0 EQU H'0000' +AD1 EQU H'0001' +AD2 EQU H'0002' +AD3 EQU H'0003' +AD4 EQU H'0004' +AD5 EQU H'0005' +AD6 EQU H'0006' +AD7 EQU H'0007' + +PSP0 EQU H'0000' +PSP1 EQU H'0001' +PSP2 EQU H'0002' +PSP3 EQU H'0003' +PSP4 EQU H'0004' +PSP5 EQU H'0005' +PSP6 EQU H'0006' +PSP7 EQU H'0007' + +CTPLS EQU H'0000' +T5CKI EQU H'0001' +SDO2 EQU H'0004' +SDI2 EQU H'0005' +SCK2 EQU H'0006' +NOT_SS2 EQU H'0007' + +T7G EQU H'0001' +SDA2 EQU H'0005' +SCL2 EQU H'0006' + + +;----- PORTE Bits ----------------------------------------------------- +RE0 EQU H'0000' +RE1 EQU H'0001' +RE2 EQU H'0002' +RE3 EQU H'0003' +RE4 EQU H'0004' +RE5 EQU H'0005' +RE6 EQU H'0006' +RE7 EQU H'0007' + +AD8 EQU H'0000' +AD9 EQU H'0001' +AD10 EQU H'0002' +AD11 EQU H'0003' +AD12 EQU H'0004' +AD13 EQU H'0005' +AD14 EQU H'0006' +AD15 EQU H'0007' + +P2D EQU H'0000' +P2C EQU H'0001' +P2B EQU H'0002' +P3C EQU H'0003' +P3B EQU H'0004' +P1C EQU H'0005' +P1B EQU H'0006' +P2A_PORTE EQU H'0007' + +CCP10 EQU H'0002' +CCP9_PORTE EQU H'0003' +CCP8_PORTE EQU H'0004' +CCP7_PORTE EQU H'0005' +CCP6_PORTE EQU H'0006' +CCP2_PORTE EQU H'0007' + +NOT_RD EQU H'0000' +NOT_WR EQU H'0001' +NOT_CS EQU H'0002' +REFO EQU H'0003' + + +;----- PORTF Bits ----------------------------------------------------- +RF1 EQU H'0001' +RF2 EQU H'0002' +RF3 EQU H'0003' +RF4 EQU H'0004' +RF5 EQU H'0005' +RF6 EQU H'0006' +RF7 EQU H'0007' + +AN6 EQU H'0001' +AN7 EQU H'0002' +AN8 EQU H'0003' +AN9 EQU H'0004' +AN10 EQU H'0005' +AN11 EQU H'0006' +AN5 EQU H'0007' + +C2OUT EQU H'0001' +C1OUT EQU H'0002' +C2INB EQU H'0003' +C2INA EQU H'0004' +C1INB EQU H'0005' +C1INA EQU H'0006' +SS1 EQU H'0007' + +CTDIN EQU H'0001' +CTMUI EQU H'0003' +CVREF EQU H'0005' + + +;----- PORTG Bits ----------------------------------------------------- +RG0 EQU H'0000' +RG1 EQU H'0001' +RG2 EQU H'0002' +RG3 EQU H'0003' +RG4 EQU H'0004' +RG5 EQU H'0005' + +CCP3 EQU H'0000' +C3OUT EQU H'0001' +C3INA EQU H'0002' +C3INB EQU H'0003' +C3INC EQU H'0004' + +PA3 EQU H'0000' +TX2 EQU H'0001' +RX2 EQU H'0002' +PD3 EQU H'0003' +PD1 EQU H'0004' + +AN19 EQU H'0001' +AN18 EQU H'0002' +AN17 EQU H'0003' +AN16 EQU H'0004' + +CK2 EQU H'0001' +DT2 EQU H'0002' +CCP4 EQU H'0003' +CCP5 EQU H'0004' + +T7CKI EQU H'0004' + +T5G EQU H'0004' + +RTCC EQU H'0004' + + +;----- PORTH Bits ----------------------------------------------------- +RH0 EQU H'0000' +RH1 EQU H'0001' +RH2 EQU H'0002' +RH3 EQU H'0003' +RH4 EQU H'0004' +RH5 EQU H'0005' +RH6 EQU H'0006' +RH7 EQU H'0007' + +AN23 EQU H'0000' +AN22 EQU H'0001' +AN21 EQU H'0002' +AN20 EQU H'0003' +AN12 EQU H'0004' +AN13 EQU H'0005' +AN14 EQU H'0006' +AN15 EQU H'0007' + +A16 EQU H'0000' +A17 EQU H'0001' +A18 EQU H'0002' +A19 EQU H'0003' +CCP9_PORTH EQU H'0004' +CCP8_PORTH EQU H'0005' +CCP7_PORTH EQU H'0006' +CCP6_PORTH EQU H'0007' + +PC3 EQU H'0004' +PB3 EQU H'0005' +PC1 EQU H'0006' +PB1 EQU H'0007' + +C2INC EQU H'0004' +C2IND EQU H'0005' +C1INC EQU H'0006' + + +;----- PORTJ Bits ----------------------------------------------------- +RJ0 EQU H'0000' +RJ1 EQU H'0001' +RJ2 EQU H'0002' +RJ3 EQU H'0003' +RJ4 EQU H'0004' +RJ5 EQU H'0005' +RJ6 EQU H'0006' +RJ7 EQU H'0007' + +ALE EQU H'0000' +OE EQU H'0001' +WRL EQU H'0002' +WRH EQU H'0003' +BA0 EQU H'0004' +CE EQU H'0005' +LB EQU H'0006' +UB EQU H'0007' + + +;----- LATA Bits ----------------------------------------------------- +LATA0 EQU H'0000' +LATA1 EQU H'0001' +LATA2 EQU H'0002' +LATA3 EQU H'0003' +LATA4 EQU H'0004' +LATA5 EQU H'0005' +LATA6 EQU H'0006' +LATA7 EQU H'0007' + + +;----- LATB Bits ----------------------------------------------------- +LATB0 EQU H'0000' +LATB1 EQU H'0001' +LATB2 EQU H'0002' +LATB3 EQU H'0003' +LATB4 EQU H'0004' +LATB5 EQU H'0005' +LATB6 EQU H'0006' +LATB7 EQU H'0007' + + +;----- LATC Bits ----------------------------------------------------- +LATC0 EQU H'0000' +LATC1 EQU H'0001' +LATC2 EQU H'0002' +LATC3 EQU H'0003' +LATC4 EQU H'0004' +LATC5 EQU H'0005' +LATC6 EQU H'0006' +LATC7 EQU H'0007' + + +;----- LATD Bits ----------------------------------------------------- +LATD0 EQU H'0000' +LATD1 EQU H'0001' +LATD2 EQU H'0002' +LATD3 EQU H'0003' +LATD4 EQU H'0004' +LATD5 EQU H'0005' +LATD6 EQU H'0006' +LATD7 EQU H'0007' + + +;----- LATE Bits ----------------------------------------------------- +LATE0 EQU H'0000' +LATE1 EQU H'0001' +LATE2 EQU H'0002' +LATE3 EQU H'0003' +LATE4 EQU H'0004' +LATE5 EQU H'0005' +LATE6 EQU H'0006' +LATE7 EQU H'0007' + + +;----- LATF Bits ----------------------------------------------------- +LATF1 EQU H'0001' +LATF2 EQU H'0002' +LATF3 EQU H'0003' +LATF4 EQU H'0004' +LATF5 EQU H'0005' +LATF6 EQU H'0006' +LATF7 EQU H'0007' + + +;----- LATG Bits ----------------------------------------------------- +LATG0 EQU H'0000' +LATG1 EQU H'0001' +LATG2 EQU H'0002' +LATG3 EQU H'0003' +LATG4 EQU H'0004' + + +;----- LATH Bits ----------------------------------------------------- +LATH0 EQU H'0000' +LATH1 EQU H'0001' +LATH2 EQU H'0002' +LATH3 EQU H'0003' +LATH4 EQU H'0004' +LATH5 EQU H'0005' +LATH6 EQU H'0006' +LATH7 EQU H'0007' + + +;----- LATJ Bits ----------------------------------------------------- +LATJ0 EQU H'0000' +LATJ1 EQU H'0001' +LATJ2 EQU H'0002' +LATJ3 EQU H'0003' +LATJ4 EQU H'0004' +LATJ5 EQU H'0005' +LATJ6 EQU H'0006' +LATJ7 EQU H'0007' + + +;----- TRISA Bits ----------------------------------------------------- +TRISA0 EQU H'0000' +TRISA1 EQU H'0001' +TRISA2 EQU H'0002' +TRISA3 EQU H'0003' +TRISA4 EQU H'0004' +TRISA5 EQU H'0005' +TRISA6 EQU H'0006' +TRISA7 EQU H'0007' + + +;----- TRISB Bits ----------------------------------------------------- +TRISB0 EQU H'0000' +TRISB1 EQU H'0001' +TRISB2 EQU H'0002' +TRISB3 EQU H'0003' +TRISB4 EQU H'0004' +TRISB5 EQU H'0005' +TRISB6 EQU H'0006' +TRISB7 EQU H'0007' + + +;----- TRISC Bits ----------------------------------------------------- +TRISC0 EQU H'0000' +TRISC1 EQU H'0001' +TRISC2 EQU H'0002' +TRISC3 EQU H'0003' +TRISC4 EQU H'0004' +TRISC5 EQU H'0005' +TRISC6 EQU H'0006' +TRISC7 EQU H'0007' + + +;----- TRISD Bits ----------------------------------------------------- +TRISD0 EQU H'0000' +TRISD1 EQU H'0001' +TRISD2 EQU H'0002' +TRISD3 EQU H'0003' +TRISD4 EQU H'0004' +TRISD5 EQU H'0005' +TRISD6 EQU H'0006' +TRISD7 EQU H'0007' + + +;----- TRISE Bits ----------------------------------------------------- +TRISE0 EQU H'0000' +TRISE1 EQU H'0001' +TRISE2 EQU H'0002' +TRISE3 EQU H'0003' +TRISE4 EQU H'0004' +TRISE5 EQU H'0005' +TRISE6 EQU H'0006' +TRISE7 EQU H'0007' + + +;----- TRISF Bits ----------------------------------------------------- +TRISF1 EQU H'0001' +TRISF2 EQU H'0002' +TRISF3 EQU H'0003' +TRISF4 EQU H'0004' +TRISF5 EQU H'0005' +TRISF6 EQU H'0006' +TRISF7 EQU H'0007' + + +;----- TRISG Bits ----------------------------------------------------- +TRISG0 EQU H'0000' +TRISG1 EQU H'0001' +TRISG2 EQU H'0002' +TRISG3 EQU H'0003' +TRISG4 EQU H'0004' + + +;----- TRISH Bits ----------------------------------------------------- +TRISH0 EQU H'0000' +TRISH1 EQU H'0001' +TRISH2 EQU H'0002' +TRISH3 EQU H'0003' +TRISH4 EQU H'0004' +TRISH5 EQU H'0005' +TRISH6 EQU H'0006' +TRISH7 EQU H'0007' + + +;----- TRISJ Bits ----------------------------------------------------- +TRISJ0 EQU H'0000' +TRISJ1 EQU H'0001' +TRISJ2 EQU H'0002' +TRISJ3 EQU H'0003' +TRISJ4 EQU H'0004' +TRISJ5 EQU H'0005' +TRISJ6 EQU H'0006' +TRISJ7 EQU H'0007' + + +;----- OSCTUNE Bits ----------------------------------------------------- +PLLEN EQU H'0006' +INTSRC EQU H'0007' + +TUN0 EQU H'0000' +TUN1 EQU H'0001' +TUN2 EQU H'0002' +TUN3 EQU H'0003' +TUN4 EQU H'0004' +TUN5 EQU H'0005' + + +;----- PSTR1CON Bits ----------------------------------------------------- +STRA EQU H'0000' +STRB EQU H'0001' +STRC EQU H'0002' +STRD EQU H'0003' +STRSYNC EQU H'0004' + +CMPL0 EQU H'0006' +CMPL1 EQU H'0007' + + +;----- PIE1 Bits ----------------------------------------------------- +TMR1IE EQU H'0000' +TMR2IE EQU H'0001' +TMR1GIE EQU H'0002' +SSP1IE EQU H'0003' +TX1IE EQU H'0004' +RC1IE EQU H'0005' +ADIE EQU H'0006' +PSPIE EQU H'0007' + +SSPIE EQU H'0003' +TXIE EQU H'0004' +RCIE EQU H'0005' + + +;----- PIR1 Bits ----------------------------------------------------- +TMR1IF EQU H'0000' +TMR2IF EQU H'0001' +TMR1GIF EQU H'0002' +SSP1IF EQU H'0003' +TX1IF EQU H'0004' +RC1IF EQU H'0005' +ADIF EQU H'0006' +PSPIF EQU H'0007' + +SSPIF EQU H'0003' +TXIF EQU H'0004' +RCIF EQU H'0005' + + +;----- IPR1 Bits ----------------------------------------------------- +TMR1IP EQU H'0000' +TMR2IP EQU H'0001' +TMR1GIP EQU H'0002' +SSP1IP EQU H'0003' +TX1IP EQU H'0004' +RC1IP EQU H'0005' +ADIP EQU H'0006' +PSPIP EQU H'0007' + +SSPIP EQU H'0003' +TXIP EQU H'0004' +RCIP EQU H'0005' + + +;----- PIE2 Bits ----------------------------------------------------- +TMR3GIE EQU H'0000' +TMR3IE EQU H'0001' +HLVDIE EQU H'0002' +BCL1IE EQU H'0003' +BCL2IE EQU H'0004' +SSP2IE EQU H'0005' +OSCFIE EQU H'0007' + +LVDIE EQU H'0002' +BCLIE EQU H'0003' + + +;----- PIR2 Bits ----------------------------------------------------- +TMR3GIF EQU H'0000' +TMR3IF EQU H'0001' +HLVDIF EQU H'0002' +BCL1IF EQU H'0003' +BCL2IF EQU H'0004' +SSP2IF EQU H'0005' +OSCFIF EQU H'0007' + +LVDIF EQU H'0002' +BCLIF EQU H'0003' + + +;----- IPR2 Bits ----------------------------------------------------- +TMR3GIP EQU H'0000' +TMR3IP EQU H'0001' +HLVDIP EQU H'0002' +BCL1IP EQU H'0003' +BCL2IP EQU H'0004' +SSP2IP EQU H'0005' +OSCFIP EQU H'0007' + +LVDIP EQU H'0002' +BCLIP EQU H'0003' + + +;----- PIE3 Bits ----------------------------------------------------- +RTCCIE EQU H'0000' +CCP1IE EQU H'0001' +CCP2IE EQU H'0002' +CTMUIE EQU H'0003' +TX2IE EQU H'0004' +RC2IE EQU H'0005' +TMR5GIE EQU H'0007' + + +;----- PIR3 Bits ----------------------------------------------------- +RTCCIF EQU H'0000' +CCP1IF EQU H'0001' +CCP2IF EQU H'0002' +CTMUIF EQU H'0003' +TX2IF EQU H'0004' +RC2IF EQU H'0005' +TMR5GIF EQU H'0007' + + +;----- IPR3 Bits ----------------------------------------------------- +RTCCIP EQU H'0000' +CCP1IP EQU H'0001' +CCP2IP EQU H'0002' +CTMUIP EQU H'0003' +TX2IP EQU H'0004' +RC2IP EQU H'0005' +TMR5GIP EQU H'0007' + + +;----- PIR6 Bits ----------------------------------------------------- +CMP1IF EQU H'0000' +CMP2IF EQU H'0001' +CMP3IF EQU H'0002' +EEIF EQU H'0004' + + +;----- PSPCON Bits ----------------------------------------------------- +PSPMODE EQU H'0004' +IBOV EQU H'0005' +OBF EQU H'0006' +IBF EQU H'0007' + + +;----- HLVDCON Bits ----------------------------------------------------- +HLVDEN EQU H'0004' +IRVST EQU H'0005' +BGVST EQU H'0006' +VDIRMAG EQU H'0007' + +HLVDL0 EQU H'0000' +HLVDL1 EQU H'0001' +HLVDL2 EQU H'0002' +HLVDL3 EQU H'0003' + + +;----- IPR6 Bits ----------------------------------------------------- +CMP1IP EQU H'0000' +CMP2IP EQU H'0001' +CMP3IP EQU H'0002' +EEIP EQU H'0004' + + +;----- T1GCON Bits ----------------------------------------------------- +T1GVAL EQU H'0002' +T1GGO_NOT_T1DONE EQU H'0003' +T1GSPM EQU H'0004' +T1GTM EQU H'0005' +T1GPOL EQU H'0006' +TMR1GE EQU H'0007' + +T1GSS0 EQU H'0000' +T1GSS1 EQU H'0001' +T1GGO EQU H'0003' + +NOT_T1DONE EQU H'0003' + + +;----- RCSTA Bits ----------------------------------------------------- +RX9D EQU H'0000' +OERR EQU H'0001' +FERR EQU H'0002' +ADDEN EQU H'0003' +CREN EQU H'0004' +SREN EQU H'0005' +RX9 EQU H'0006' +SPEN EQU H'0007' + +RCD8 EQU H'0000' +ADEN EQU H'0003' +RC9 EQU H'0006' + +NOT_RC8 EQU H'0006' + +RC8_9 EQU H'0006' + +RX9D1 EQU H'0000' +OERR1 EQU H'0001' +FERR1 EQU H'0002' +ADDEN1 EQU H'0003' +CREN1 EQU H'0004' +SREN1 EQU H'0005' +RX91 EQU H'0006' +SPEN1 EQU H'0007' + + +;----- RCSTA1 Bits ----------------------------------------------------- +RX9D EQU H'0000' +OERR EQU H'0001' +FERR EQU H'0002' +ADDEN EQU H'0003' +CREN EQU H'0004' +SREN EQU H'0005' +RX9 EQU H'0006' +SPEN EQU H'0007' + +RCD8 EQU H'0000' +ADEN EQU H'0003' +RC9 EQU H'0006' + +NOT_RC8 EQU H'0006' + +RC8_9 EQU H'0006' + +RX9D1 EQU H'0000' +OERR1 EQU H'0001' +FERR1 EQU H'0002' +ADDEN1 EQU H'0003' +CREN1 EQU H'0004' +SREN1 EQU H'0005' +RX91 EQU H'0006' +SPEN1 EQU H'0007' + + +;----- TXSTA Bits ----------------------------------------------------- +TX9D EQU H'0000' +TRMT EQU H'0001' +BRGH EQU H'0002' +SENDB EQU H'0003' +SYNC EQU H'0004' +TXEN EQU H'0005' +TX9 EQU H'0006' +CSRC EQU H'0007' + +TXD8 EQU H'0000' +TX8_9 EQU H'0006' + +NOT_TX8 EQU H'0006' + +TX9D1 EQU H'0000' +TRMT1 EQU H'0001' +BRGH1 EQU H'0002' +SENDB1 EQU H'0003' +SYNC1 EQU H'0004' +TXEN1 EQU H'0005' +TX91 EQU H'0006' +CSRC1 EQU H'0007' + + +;----- TXSTA1 Bits ----------------------------------------------------- +TX9D EQU H'0000' +TRMT EQU H'0001' +BRGH EQU H'0002' +SENDB EQU H'0003' +SYNC EQU H'0004' +TXEN EQU H'0005' +TX9 EQU H'0006' +CSRC EQU H'0007' + +TXD8 EQU H'0000' +TX8_9 EQU H'0006' + +NOT_TX8 EQU H'0006' + +TX9D1 EQU H'0000' +TRMT1 EQU H'0001' +BRGH1 EQU H'0002' +SENDB1 EQU H'0003' +SYNC1 EQU H'0004' +TXEN1 EQU H'0005' +TX91 EQU H'0006' +CSRC1 EQU H'0007' + + +;----- T3GCON Bits ----------------------------------------------------- +T3GVAL EQU H'0002' +T3GGO_NOT_T3DONE EQU H'0003' +T3GSPM EQU H'0004' +T3GTM EQU H'0005' +T3GPOL EQU H'0006' +TMR3GE EQU H'0007' + +T3GSS0 EQU H'0000' +T3GSS1 EQU H'0001' +T3GGO EQU H'0003' + +NOT_T3DONE EQU H'0003' + + +;----- T3CON Bits ----------------------------------------------------- +TMR3ON EQU H'0000' +RD16 EQU H'0001' +NOT_T3SYNC EQU H'0002' +SOSCEN EQU H'0003' + +T3CKPS0 EQU H'0004' +T3CKPS1 EQU H'0005' +TMR3CS0 EQU H'0006' +TMR3CS1 EQU H'0007' + + +;----- CMSTAT Bits ----------------------------------------------------- +CMP1OUT EQU H'0005' +CMP2OUT EQU H'0006' +CMP3OUT EQU H'0007' + + +;----- CMSTATUS Bits ----------------------------------------------------- +CMP1OUT EQU H'0005' +CMP2OUT EQU H'0006' +CMP3OUT EQU H'0007' + + +;----- CVRCON Bits ----------------------------------------------------- +CVRSS EQU H'0005' +CVROE EQU H'0006' +CVREN EQU H'0007' + +CVR0 EQU H'0000' +CVR1 EQU H'0001' +CVR2 EQU H'0002' +CVR3 EQU H'0003' +CVR4 EQU H'0004' + + +;----- PIE4 Bits ----------------------------------------------------- +CCP3IE EQU H'0000' +CCP4IE EQU H'0001' +CCP5IE EQU H'0002' +CCP6IE EQU H'0003' +CCP7IE EQU H'0004' +CCP8IE EQU H'0005' +CCP9IE EQU H'0006' +CCP10IE EQU H'0007' + + +;----- PIR4 Bits ----------------------------------------------------- +CCP3IF EQU H'0000' +CCP4IF EQU H'0001' +CCP5IF EQU H'0002' +CCP6IF EQU H'0003' +CCP7IF EQU H'0004' +CCP8IF EQU H'0005' +CCP9IF EQU H'0006' +CCP10IF EQU H'0007' + + +;----- IPR4 Bits ----------------------------------------------------- +CCP3IP EQU H'0000' +CCP4IP EQU H'0001' +CCP5IP EQU H'0002' +CCP6IP EQU H'0003' +CCP7IP EQU H'0004' +CCP8IP EQU H'0005' +CCP9IP EQU H'0006' +CCP10IP EQU H'0007' + + +;----- PIE5 Bits ----------------------------------------------------- +TMR4IE EQU H'0000' +TMR5IE EQU H'0001' +TMR6IE EQU H'0002' +TMR7IE EQU H'0003' +TMR8IE EQU H'0004' +TMR10IE EQU H'0005' +TMR12IE EQU H'0006' +TMR7GIE EQU H'0007' + + +;----- PIR5 Bits ----------------------------------------------------- +TMR4IF EQU H'0000' +TMR5IF EQU H'0001' +TMR6IF EQU H'0002' +TMR7IF EQU H'0003' +TMR8IF EQU H'0004' +TMR10IF EQU H'0005' +TMR12IF EQU H'0006' +TMR7GIF EQU H'0007' + + +;----- CCP1CON Bits ----------------------------------------------------- +CCP1M0 EQU H'0000' +CCP1M1 EQU H'0001' +CCP1M2 EQU H'0002' +CCP1M3 EQU H'0003' +DC1B0 EQU H'0004' +DC1B1 EQU H'0005' +P1M0 EQU H'0006' +P1M1 EQU H'0007' + +CCP1Y EQU H'0004' +CCP1X EQU H'0005' + + +;----- ECCP1CON Bits ----------------------------------------------------- +CCP1M0 EQU H'0000' +CCP1M1 EQU H'0001' +CCP1M2 EQU H'0002' +CCP1M3 EQU H'0003' +DC1B0 EQU H'0004' +DC1B1 EQU H'0005' +P1M0 EQU H'0006' +P1M1 EQU H'0007' + +CCP1Y EQU H'0004' +CCP1X EQU H'0005' + + +;----- ECCP1DEL Bits ----------------------------------------------------- +P1RSEN EQU H'0007' + +P1DC0 EQU H'0000' +P1DC1 EQU H'0001' +P1DC2 EQU H'0002' +P1DC3 EQU H'0003' +P1DC4 EQU H'0004' +P1DC5 EQU H'0005' +P1DC6 EQU H'0006' + + +;----- PWM1CON Bits ----------------------------------------------------- +P1RSEN EQU H'0007' + +P1DC0 EQU H'0000' +P1DC1 EQU H'0001' +P1DC2 EQU H'0002' +P1DC3 EQU H'0003' +P1DC4 EQU H'0004' +P1DC5 EQU H'0005' +P1DC6 EQU H'0006' + + +;----- ECCP1AS Bits ----------------------------------------------------- +ECCP1ASE EQU H'0007' + +PSS1BD0 EQU H'0000' +PSS1BD1 EQU H'0001' +PSS1AC0 EQU H'0002' +PSS1AC1 EQU H'0003' +ECCP1AS0 EQU H'0004' +ECCP1AS1 EQU H'0005' +ECCP1AS2 EQU H'0006' + + +;----- ADCON2 Bits ----------------------------------------------------- +ADFM EQU H'0007' + +ADCS0 EQU H'0000' +ADCS1 EQU H'0001' +ADCS2 EQU H'0002' +ACQT0 EQU H'0003' +ACQT1 EQU H'0004' +ACQT2 EQU H'0005' + + +;----- ADCON1 Bits ----------------------------------------------------- +VNCFG EQU H'0003' + +CHSN0 EQU H'0000' +CHSN1 EQU H'0001' +CHSN2 EQU H'0002' +VCFG0 EQU H'0004' +VCFG1 EQU H'0005' +TRIGSEL0 EQU H'0006' +TRIGSEL1 EQU H'0007' + + +;----- ADCON0 Bits ----------------------------------------------------- +ADON EQU H'0000' +GO_NOT_DONE EQU H'0001' + +DONE EQU H'0001' +CHS0 EQU H'0002' +CHS1 EQU H'0003' +CHS2 EQU H'0004' +CHS3 EQU H'0005' +CHS4 EQU H'0006' + +GO EQU H'0001' + +NOT_DONE EQU H'0001' + + +;----- SSP1CON2 Bits ----------------------------------------------------- +SEN EQU H'0000' +RSEN EQU H'0001' +PEN EQU H'0002' +RCEN EQU H'0003' +ACKEN EQU H'0004' +ACKDT EQU H'0005' +ACKSTAT EQU H'0006' +GCEN EQU H'0007' + +ADMSK1 EQU H'0001' +ADMSK2 EQU H'0002' +ADMSK3 EQU H'0003' +ADMSK4 EQU H'0004' +ADMSK5 EQU H'0005' + + +;----- SSPCON2 Bits ----------------------------------------------------- +SEN EQU H'0000' +RSEN EQU H'0001' +PEN EQU H'0002' +RCEN EQU H'0003' +ACKEN EQU H'0004' +ACKDT EQU H'0005' +ACKSTAT EQU H'0006' +GCEN EQU H'0007' + +ADMSK1 EQU H'0001' +ADMSK2 EQU H'0002' +ADMSK3 EQU H'0003' +ADMSK4 EQU H'0004' +ADMSK5 EQU H'0005' + + +;----- SSP1CON1 Bits ----------------------------------------------------- +CKP EQU H'0004' +SSPEN EQU H'0005' +SSPOV EQU H'0006' +WCOL EQU H'0007' + +SSPM0 EQU H'0000' +SSPM1 EQU H'0001' +SSPM2 EQU H'0002' +SSPM3 EQU H'0003' + + +;----- SSPCON1 Bits ----------------------------------------------------- +CKP EQU H'0004' +SSPEN EQU H'0005' +SSPOV EQU H'0006' +WCOL EQU H'0007' + +SSPM0 EQU H'0000' +SSPM1 EQU H'0001' +SSPM2 EQU H'0002' +SSPM3 EQU H'0003' + + +;----- SSP1STAT Bits ----------------------------------------------------- +BF EQU H'0000' +UA EQU H'0001' +R_NOT_W EQU H'0002' +S EQU H'0003' +P EQU H'0004' +D_NOT_A EQU H'0005' +CKE EQU H'0006' +SMP EQU H'0007' + +R EQU H'0002' +D EQU H'0005' + +R_W EQU H'0002' +D_A EQU H'0005' + +NOT_W EQU H'0002' +NOT_A EQU H'0005' + +NOT_WRITE EQU H'0002' +NOT_ADDRESS EQU H'0005' + +READ_WRITE EQU H'0002' +DATA_ADDRESS EQU H'0005' + +I2C_READ EQU H'0002' +I2C_START EQU H'0003' +I2C_STOP EQU H'0004' +I2C_DAT EQU H'0005' + + +;----- SSPSTAT Bits ----------------------------------------------------- +BF EQU H'0000' +UA EQU H'0001' +R_NOT_W EQU H'0002' +S EQU H'0003' +P EQU H'0004' +D_NOT_A EQU H'0005' +CKE EQU H'0006' +SMP EQU H'0007' + +R EQU H'0002' +D EQU H'0005' + +R_W EQU H'0002' +D_A EQU H'0005' + +NOT_W EQU H'0002' +NOT_A EQU H'0005' + +NOT_WRITE EQU H'0002' +NOT_ADDRESS EQU H'0005' + +READ_WRITE EQU H'0002' +DATA_ADDRESS EQU H'0005' + +I2C_READ EQU H'0002' +I2C_START EQU H'0003' +I2C_STOP EQU H'0004' +I2C_DAT EQU H'0005' + + +;----- SSP1MSK Bits ----------------------------------------------------- +MSK0 EQU H'0000' +MSK1 EQU H'0001' +MSK2 EQU H'0002' +MSK3 EQU H'0003' +MSK4 EQU H'0004' +MSK5 EQU H'0005' +MSK6 EQU H'0006' +MSK7 EQU H'0007' + + +;----- T2CON Bits ----------------------------------------------------- +TMR2ON EQU H'0002' + +T2CKPS0 EQU H'0000' +T2CKPS1 EQU H'0001' +T2OUTPS0 EQU H'0003' +T2OUTPS1 EQU H'0004' +T2OUTPS2 EQU H'0005' +T2OUTPS3 EQU H'0006' + + +;----- T1CON Bits ----------------------------------------------------- +TMR1ON EQU H'0000' +RD16 EQU H'0001' +NOT_T1SYNC EQU H'0002' +SOSCEN EQU H'0003' + +T1CKPS0 EQU H'0004' +T1CKPS1 EQU H'0005' +TMR1CS0 EQU H'0006' +TMR1CS1 EQU H'0007' + + +;----- RCON Bits ----------------------------------------------------- +NOT_BOR EQU H'0000' +NOT_POR EQU H'0001' +NOT_PD EQU H'0002' +NOT_TO EQU H'0003' +NOT_RI EQU H'0004' +NOT_CM EQU H'0005' +SBOREN EQU H'0006' +IPEN EQU H'0007' + +BOR EQU H'0000' +POR EQU H'0001' +PD EQU H'0002' +TO EQU H'0003' +RI EQU H'0004' +CM EQU H'0005' + + +;----- WDTCON Bits ----------------------------------------------------- +SWDTEN EQU H'0000' +ULPSINK EQU H'0001' +ULPEN EQU H'0002' +SRETEN EQU H'0004' +ULPLVL EQU H'0005' +REGSLP EQU H'0007' + +SWDTE EQU H'0000' + + +;----- IPR5 Bits ----------------------------------------------------- +TMR4IP EQU H'0000' +TMR5IP EQU H'0001' +TMR6IP EQU H'0002' +TMR7IP EQU H'0003' +TMR8IP EQU H'0004' +TMR10IP EQU H'0005' +TMR12IP EQU H'0006' +TMR7GIP EQU H'0007' + + +;----- OSCCON Bits ----------------------------------------------------- +HFIOFS EQU H'0002' +OSTS EQU H'0003' +IDLEN EQU H'0007' + +SCS0 EQU H'0000' +SCS1 EQU H'0001' +IRCF0 EQU H'0004' +IRCF1 EQU H'0005' +IRCF2 EQU H'0006' + + +;----- T0CON Bits ----------------------------------------------------- +PSA EQU H'0003' +T0SE EQU H'0004' +T0CS EQU H'0005' +T08BIT EQU H'0006' +TMR0ON EQU H'0007' + +T0PS0 EQU H'0000' +T0PS1 EQU H'0001' +T0PS2 EQU H'0002' + + +;----- STATUS Bits ----------------------------------------------------- +C EQU H'0000' +DC EQU H'0001' +Z EQU H'0002' +OV EQU H'0003' +N EQU H'0004' + + +;----- INTCON3 Bits ----------------------------------------------------- +INT1IF EQU H'0000' +INT2IF EQU H'0001' +INT3IF EQU H'0002' +INT1IE EQU H'0003' +INT2IE EQU H'0004' +INT3IE EQU H'0005' +INT1IP EQU H'0006' +INT2IP EQU H'0007' + +INT1F EQU H'0000' +INT2F EQU H'0001' +INT3F EQU H'0002' +INT1E EQU H'0003' +INT2E EQU H'0004' +INT3E EQU H'0005' +INT1P EQU H'0006' +INT2P EQU H'0007' + + +;----- INTCON2 Bits ----------------------------------------------------- +RBIP EQU H'0000' +INT3IP EQU H'0001' +TMR0IP EQU H'0002' +INTEDG3 EQU H'0003' +INTEDG2 EQU H'0004' +INTEDG1 EQU H'0005' +INTEDG0 EQU H'0006' +NOT_RBPU EQU H'0007' + +INT3P EQU H'0001' +T0IP EQU H'0002' +RBPU EQU H'0007' + + +;----- INTCON Bits ----------------------------------------------------- +RBIF EQU H'0000' +INT0IF EQU H'0001' +TMR0IF EQU H'0002' +RBIE EQU H'0003' +INT0IE EQU H'0004' +TMR0IE EQU H'0005' +PEIE_GIEL EQU H'0006' +GIE_GIEH EQU H'0007' + +INT0F EQU H'0001' +T0IF EQU H'0002' +INT0E EQU H'0004' +T0IE EQU H'0005' +PEIE EQU H'0006' +GIE EQU H'0007' + +GIEL EQU H'0006' +GIEH EQU H'0007' + + +;----- STKPTR Bits ----------------------------------------------------- +STKUNF EQU H'0006' +STKFUL EQU H'0007' + +SP0 EQU H'0000' +SP1 EQU H'0001' +SP2 EQU H'0002' +SP3 EQU H'0003' +SP4 EQU H'0004' +STKOVF EQU H'0007' + + + +;========================================================================== +; +; RAM Definitions +; +;========================================================================== + __MAXRAM H'0FFF' + +;========================================================================== +; +; IMPORTANT: For the PIC18 devices, the __CONFIG directive has been +; superseded by the CONFIG directive. The following settings +; are available for this device. +; +; VREG Sleep Enable bit: +; RETEN = OFF Disabled - Controlled by SRETEN bit +; RETEN = ON Enabled +; +; LF-INTOSC Low-power Enable bit: +; INTOSCSEL = LOW LF-INTOSC in Low-power mode during Sleep +; INTOSCSEL = HIGH LF-INTOSC in High-power mode during Sleep +; +; SOSC Power Selection and mode Configuration bits: +; SOSCSEL = LOW Low Power SOSC circuit selected +; SOSCSEL = DIG Digital (SCLKI) mode +; SOSCSEL = HIGH High Power SOSC circuit selected +; +; Extended Instruction Set: +; XINST = OFF Disabled +; XINST = ON Enabled +; +; Oscillator: +; FOSC = LP LP oscillator +; FOSC = XT XT oscillator +; FOSC = HS2 HS oscillator (High power, 16 MHz - 25 MHz) +; FOSC = HS1 HS oscillator (Medium power, 4 MHz - 16 MHz) +; FOSC = EC3IO EC oscillator, CLKOUT function on OSC2 (High power, 16 MHz - 64 MHz) +; FOSC = EC3 EC oscillator (High power, 16 MHz - 64 MHz) +; FOSC = RC External RC oscillator, CLKOUT function on OSC2 +; FOSC = RCIO External RC oscillator +; FOSC = INTIO2 Internal RC oscillator +; FOSC = INTIO1 Internal RC oscillator, CLKOUT function on OSC2 +; FOSC = EC2IO EC oscillator, CLKOUT function on OSC2 (Medium power, 160 kHz - 4 MHz) +; FOSC = EC2 EC oscillator (Medium power, 160 kHz - 4 MHz) +; FOSC = EC1IO EC oscillator, CLKOUT function on OSC2 (Low power, DC - 160 kHz) +; FOSC = EC1 EC oscillator (Low power, DC - 160 kHz) +; +; PLL x4 Enable bit: +; PLLCFG = OFF Disabled +; PLLCFG = ON Enabled +; +; Fail-Safe Clock Monitor: +; FCMEN = OFF Disabled +; FCMEN = ON Enabled +; +; Internal External Oscillator Switch Over Mode: +; IESO = OFF Disabled +; IESO = ON Enabled +; +; Power Up Timer: +; PWRTEN = ON Enabled +; PWRTEN = OFF Disabled +; +; Brown Out Detect: +; BOREN = OFF Disabled in hardware, SBOREN disabled +; BOREN = ON Controlled with SBOREN bit +; BOREN = NOSLP Enabled while active, disabled in SLEEP, SBOREN disabled +; BOREN = SBORDIS Enabled in hardware, SBOREN disabled +; +; Brown-out Reset Voltage bits: +; BORV = 0 3.0V +; BORV = 1 2.7V +; BORV = 2 2.0V +; BORV = 3 1.8V +; +; BORMV Power level: +; BORPWR = LOW BORMV set to low power level +; BORPWR = MEDIUM BORMV set to medium power level +; BORPWR = HIGH BORMV set to high power level +; BORPWR = ZPBORMV ZPBORMV instead of BORMV is selected +; +; Watchdog Timer: +; WDTEN = OFF WDT disabled in hardware; SWDTEN bit disabled +; WDTEN = NOSLP WDT enabled only while device is active and disabled in Sleep mode; SWDTEN bit disabled +; WDTEN = ON WDT controlled by SWDTEN bit setting +; WDTEN = SWDTDIS WDT enabled in hardware; SWDTEN bit disabled +; +; Watchdog Postscaler: +; WDTPS = 1 1:1 +; WDTPS = 2 1:2 +; WDTPS = 4 1:4 +; WDTPS = 8 1:8 +; WDTPS = 16 1:16 +; WDTPS = 32 1:32 +; WDTPS = 64 1:64 +; WDTPS = 128 1:128 +; WDTPS = 256 1:256 +; WDTPS = 512 1:512 +; WDTPS = 1024 1:1024 +; WDTPS = 2048 1:2048 +; WDTPS = 4096 1:4096 +; WDTPS = 8192 1:8192 +; WDTPS = 16384 1:16384 +; WDTPS = 32768 1:32768 +; WDTPS = 65536 1:65536 +; WDTPS = 131072 1:131072 +; WDTPS = 262144 1:262144 +; WDTPS = 524288 1:524288 +; WDTPS = 1048576 1:1048576 +; +; RTCC Clock Select: +; RTCOSC = INTOSCREF RTCC uses INTRC +; RTCOSC = SOSCREF RTCC uses SOSC +; +; External Address Shift bit: +; EASHFT = OFF Address Shifting disabled +; EASHFT = ON Address Shifting enabled +; +; Address Bus Width Select bits: +; ABW = XM20 20-bit address bus +; ABW = XM16 16-bit address bus +; ABW = XM12 12-bit address bus +; ABW = MM 8-bit address bus +; +; Data Bus Width: +; BW = 8 8-bit external bus mode +; BW = 16 16-bit external bus mode +; +; External Bus Wait: +; WAIT = ON Enabled +; WAIT = OFF Disabled +; +; CCP2 Mux: +; CCP2MX = PORTBE RE7-Microcontroller Mode/RB3-All other modes +; CCP2MX = PORTC RC1 +; +; ECCP Mux: +; ECCPMX = PORTH Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RH7/RH6/RH5/RH4 +; ECCPMX = PORTE Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RE6/RE5/RE4/RE3 +; +; MSSP address masking: +; MSSPMSK = MSK5 5 bit address masking mode +; MSSPMSK = MSK7 7 Bit address masking mode +; +; Master Clear Enable: +; MCLRE = OFF MCLR Disabled, RG5 Enabled +; MCLRE = ON MCLR Enabled, RG5 Disabled +; +; Stack Overflow Reset: +; STVREN = OFF Disabled +; STVREN = ON Enabled +; +; Boot Block Size: +; BBSIZ = BB1K 1K word Boot Block size +; BBSIZ = BB2K 2K word Boot Block size +; +; Background Debug: +; DEBUG = ON Enabled +; DEBUG = OFF Disabled +; +; Code Protect 00800-03FFF: +; CP0 = ON Enabled +; CP0 = OFF Disabled +; +; Code Protect 04000-07FFF: +; CP1 = ON Enabled +; CP1 = OFF Disabled +; +; Code Protect 08000-0BFFF: +; CP2 = ON Enabled +; CP2 = OFF Disabled +; +; Code Protect 0C000-0FFFF: +; CP3 = ON Enabled +; CP3 = OFF Disabled +; +; Code Protect 10000-13FFF: +; CP4 = ON Enabled +; CP4 = OFF Disabled +; +; Code Protect 14000-17FFF: +; CP5 = ON Enabled +; CP5 = OFF Disabled +; +; Code Protect 18000-1BFFF: +; CP6 = ON Enabled +; CP6 = OFF Disabled +; +; Code Protect 1C000-1FFFF: +; CP7 = ON Enabled +; CP7 = OFF Disabled +; +; Code Protect Boot: +; CPB = ON Enabled +; CPB = OFF Disabled +; +; Data EE Read Protect: +; CPD = ON Enabled +; CPD = OFF Disabled +; +; Table Write Protect 00800-03FFF: +; WRT0 = ON Enabled +; WRT0 = OFF Disabled +; +; Table Write Protect 04000-07FFF: +; WRT1 = ON Enabled +; WRT1 = OFF Disabled +; +; Table Write Protect 08000-0BFFF: +; WRT2 = ON Enabled +; WRT2 = OFF Disabled +; +; Table Write Protect 0C000-0FFFF: +; WRT3 = ON Enabled +; WRT3 = OFF Disabled +; +; Table Write Protect 10000-13FFF: +; WRT4 = ON Enabled +; WRT4 = OFF Disabled +; +; Table Write Protect 14000-17FFF: +; WRT5 = ON Enabled +; WRT5 = OFF Disabled +; +; Table Write Protect 18000-1BFFF: +; WRT6 = ON Enabled +; WRT6 = OFF Disabled +; +; Table Write Protect 1C000-1FFFF: +; WRT7 = ON Enabled +; WRT7 = OFF Disabled +; +; Config. Write Protect: +; WRTC = ON Enabled +; WRTC = OFF Disabled +; +; Table Write Protect Boot: +; WRTB = ON Enabled +; WRTB = OFF Disabled +; +; Data EE Write Protect: +; WRTD = ON Enabled +; WRTD = OFF Disabled +; +; Table Read Protect 00800-03FFF: +; EBRT0 = ON Enabled +; EBRT0 = OFF Disabled +; +; Table Read Protect 04000-07FFF: +; EBRT1 = ON Enabled +; EBRT1 = OFF Disabled +; +; Table Read Protect 08000-0BFFF: +; EBRT2 = ON Enabled +; EBRT2 = OFF Disabled +; +; Table Read Protect 0C000-0FFFF: +; EBRT3 = ON Enabled +; EBRT3 = OFF Disabled +; +; Table Read Protect 10000-13FFF: +; EBRT4 = ON Enabled +; EBRT4 = OFF Disabled +; +; Table Read Protect 14000-17FFF: +; EBRT5 = ON Enabled +; EBRT5 = OFF Disabled +; +; Table Read Protect 18000-1BFFF: +; EBRT6 = ON Enabled +; EBRT6 = OFF Disabled +; +; Table Read Protect 1C000-1FFFF: +; EBRT7 = ON Enabled +; EBRT7 = OFF Disabled +; +; Table Read Protect Boot: +; EBRTB = ON Enabled +; EBRTB = OFF Disabled +; +;========================================================================== +;========================================================================== +; +; Configuration Bits +; +; NAME Address +; CONFIG1L 300000h +; CONFIG1H 300001h +; CONFIG2L 300002h +; CONFIG2H 300003h +; CONFIG3L 300004h +; CONFIG3H 300005h +; CONFIG4L 300006h +; CONFIG5L 300008h +; CONFIG5H 300009h +; CONFIG6L 30000Ah +; CONFIG6H 30000Bh +; CONFIG7L 30000Ch +; CONFIG7H 30000Dh +; +;========================================================================== + +; The following is an assignment of address values for all of the +; configuration registers for the purpose of table reads +_CONFIG1L EQU H'300000' +_CONFIG1H EQU H'300001' +_CONFIG2L EQU H'300002' +_CONFIG2H EQU H'300003' +_CONFIG3L EQU H'300004' +_CONFIG3H EQU H'300005' +_CONFIG4L EQU H'300006' +_CONFIG5L EQU H'300008' +_CONFIG5H EQU H'300009' +_CONFIG6L EQU H'30000A' +_CONFIG6H EQU H'30000B' +_CONFIG7L EQU H'30000C' +_CONFIG7H EQU H'30000D' + +;----- CONFIG1L Options -------------------------------------------------- +_RETEN_OFF_1L EQU H'FE' ; Disabled - Controlled by SRETEN bit +_RETEN_ON_1L EQU H'FF' ; Enabled + +_INTOSCSEL_LOW_1L EQU H'FB' ; LF-INTOSC in Low-power mode during Sleep +_INTOSCSEL_HIGH_1L EQU H'FF' ; LF-INTOSC in High-power mode during Sleep + +_SOSCSEL_LOW_1L EQU H'EF' ; Low Power SOSC circuit selected +_SOSCSEL_DIG_1L EQU H'F7' ; Digital (SCLKI) mode +_SOSCSEL_HIGH_1L EQU H'FF' ; High Power SOSC circuit selected + +_XINST_OFF_1L EQU H'BF' ; Disabled +_XINST_ON_1L EQU H'FF' ; Enabled + +;----- CONFIG1H Options -------------------------------------------------- +_FOSC_LP_1H EQU H'F0' ; LP oscillator +_FOSC_XT_1H EQU H'F1' ; XT oscillator +_FOSC_HS2_1H EQU H'F2' ; HS oscillator (High power, 16 MHz - 25 MHz) +_FOSC_HS1_1H EQU H'F3' ; HS oscillator (Medium power, 4 MHz - 16 MHz) +_FOSC_EC3IO_1H EQU H'F4' ; EC oscillator, CLKOUT function on OSC2 (High power, 16 MHz - 64 MHz) +_FOSC_EC3_1H EQU H'F5' ; EC oscillator (High power, 16 MHz - 64 MHz) +_FOSC_RC_1H EQU H'F6' ; External RC oscillator, CLKOUT function on OSC2 +_FOSC_RCIO_1H EQU H'F7' ; External RC oscillator +_FOSC_INTIO2_1H EQU H'F8' ; Internal RC oscillator +_FOSC_INTIO1_1H EQU H'F9' ; Internal RC oscillator, CLKOUT function on OSC2 +_FOSC_EC2IO_1H EQU H'FA' ; EC oscillator, CLKOUT function on OSC2 (Medium power, 160 kHz - 4 MHz) +_FOSC_EC2_1H EQU H'FB' ; EC oscillator (Medium power, 160 kHz - 4 MHz) +_FOSC_EC1IO_1H EQU H'FC' ; EC oscillator, CLKOUT function on OSC2 (Low power, DC - 160 kHz) +_FOSC_EC1_1H EQU H'FD' ; EC oscillator (Low power, DC - 160 kHz) + +_PLLCFG_OFF_1H EQU H'EF' ; Disabled +_PLLCFG_ON_1H EQU H'FF' ; Enabled + +_FCMEN_OFF_1H EQU H'BF' ; Disabled +_FCMEN_ON_1H EQU H'FF' ; Enabled + +_IESO_OFF_1H EQU H'7F' ; Disabled +_IESO_ON_1H EQU H'FF' ; Enabled + +;----- CONFIG2L Options -------------------------------------------------- +_PWRTEN_ON_2L EQU H'FE' ; Enabled +_PWRTEN_OFF_2L EQU H'FF' ; Disabled + +_BOREN_OFF_2L EQU H'F9' ; Disabled in hardware, SBOREN disabled +_BOREN_ON_2L EQU H'FB' ; Controlled with SBOREN bit +_BOREN_NOSLP_2L EQU H'FD' ; Enabled while active, disabled in SLEEP, SBOREN disabled +_BOREN_SBORDIS_2L EQU H'FF' ; Enabled in hardware, SBOREN disabled + +_BORV_0_2L EQU H'E7' ; 3.0V +_BORV_1_2L EQU H'EF' ; 2.7V +_BORV_2_2L EQU H'F7' ; 2.0V +_BORV_3_2L EQU H'FF' ; 1.8V + +_BORPWR_LOW_2L EQU H'9F' ; BORMV set to low power level +_BORPWR_MEDIUM_2L EQU H'BF' ; BORMV set to medium power level +_BORPWR_HIGH_2L EQU H'DF' ; BORMV set to high power level +_BORPWR_ZPBORMV_2L EQU H'FF' ; ZPBORMV instead of BORMV is selected + +;----- CONFIG2H Options -------------------------------------------------- +_WDTEN_OFF_2H EQU H'FC' ; WDT disabled in hardware; SWDTEN bit disabled +_WDTEN_NOSLP_2H EQU H'FD' ; WDT enabled only while device is active and disabled in Sleep mode; SWDTEN bit disabled +_WDTEN_ON_2H EQU H'FE' ; WDT controlled by SWDTEN bit setting +_WDTEN_SWDTDIS_2H EQU H'FF' ; WDT enabled in hardware; SWDTEN bit disabled + +_WDTPS_1_2H EQU H'83' ; 1:1 +_WDTPS_2_2H EQU H'87' ; 1:2 +_WDTPS_4_2H EQU H'8B' ; 1:4 +_WDTPS_8_2H EQU H'8F' ; 1:8 +_WDTPS_16_2H EQU H'93' ; 1:16 +_WDTPS_32_2H EQU H'97' ; 1:32 +_WDTPS_64_2H EQU H'9B' ; 1:64 +_WDTPS_128_2H EQU H'9F' ; 1:128 +_WDTPS_256_2H EQU H'A3' ; 1:256 +_WDTPS_512_2H EQU H'A7' ; 1:512 +_WDTPS_1024_2H EQU H'AB' ; 1:1024 +_WDTPS_2048_2H EQU H'AF' ; 1:2048 +_WDTPS_4096_2H EQU H'B3' ; 1:4096 +_WDTPS_8192_2H EQU H'B7' ; 1:8192 +_WDTPS_16384_2H EQU H'BB' ; 1:16384 +_WDTPS_32768_2H EQU H'BF' ; 1:32768 +_WDTPS_65536_2H EQU H'C3' ; 1:65536 +_WDTPS_131072_2H EQU H'C7' ; 1:131072 +_WDTPS_262144_2H EQU H'CB' ; 1:262144 +_WDTPS_524288_2H EQU H'CF' ; 1:524288 +_WDTPS_1048576_2H EQU H'FF' ; 1:1048576 + +;----- CONFIG3L Options -------------------------------------------------- +_RTCOSC_INTOSCREF_3L EQU H'FE' ; RTCC uses INTRC +_RTCOSC_SOSCREF_3L EQU H'FF' ; RTCC uses SOSC + +_EASHFT_OFF_3L EQU H'F7' ; Address Shifting disabled +_EASHFT_ON_3L EQU H'FF' ; Address Shifting enabled + +_ABW_XM20_3L EQU H'CF' ; 20-bit address bus +_ABW_XM16_3L EQU H'DF' ; 16-bit address bus +_ABW_XM12_3L EQU H'EF' ; 12-bit address bus +_ABW_MM_3L EQU H'FF' ; 8-bit address bus + +_BW_8_3L EQU H'BF' ; 8-bit external bus mode +_BW_16_3L EQU H'FF' ; 16-bit external bus mode + +_WAIT_ON_3L EQU H'7F' ; Enabled +_WAIT_OFF_3L EQU H'FF' ; Disabled + +;----- CONFIG3H Options -------------------------------------------------- +_CCP2MX_PORTBE_3H EQU H'FE' ; RE7-Microcontroller Mode/RB3-All other modes +_CCP2MX_PORTC_3H EQU H'FF' ; RC1 + +_ECCPMX_PORTH_3H EQU H'FD' ; Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RH7/RH6/RH5/RH4 +_ECCPMX_PORTE_3H EQU H'FF' ; Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RE6/RE5/RE4/RE3 + +_MSSPMSK_MSK5_3H EQU H'F7' ; 5 bit address masking mode +_MSSPMSK_MSK7_3H EQU H'FF' ; 7 Bit address masking mode + +_MCLRE_OFF_3H EQU H'7F' ; MCLR Disabled, RG5 Enabled +_MCLRE_ON_3H EQU H'FF' ; MCLR Enabled, RG5 Disabled + +;----- CONFIG4L Options -------------------------------------------------- +_STVREN_OFF_4L EQU H'FE' ; Disabled +_STVREN_ON_4L EQU H'FF' ; Enabled + +_BBSIZ_BB1K_4L EQU H'EF' ; 1K word Boot Block size +_BBSIZ_BB2K_4L EQU H'FF' ; 2K word Boot Block size + +_DEBUG_ON_4L EQU H'7F' ; Enabled +_DEBUG_OFF_4L EQU H'FF' ; Disabled + +;----- CONFIG5L Options -------------------------------------------------- +_CP0_ON_5L EQU H'FE' ; Enabled +_CP0_OFF_5L EQU H'FF' ; Disabled + +_CP1_ON_5L EQU H'FD' ; Enabled +_CP1_OFF_5L EQU H'FF' ; Disabled + +_CP2_ON_5L EQU H'FB' ; Enabled +_CP2_OFF_5L EQU H'FF' ; Disabled + +_CP3_ON_5L EQU H'F7' ; Enabled +_CP3_OFF_5L EQU H'FF' ; Disabled + +_CP4_ON_5L EQU H'EF' ; Enabled +_CP4_OFF_5L EQU H'FF' ; Disabled + +_CP5_ON_5L EQU H'DF' ; Enabled +_CP5_OFF_5L EQU H'FF' ; Disabled + +_CP6_ON_5L EQU H'BF' ; Enabled +_CP6_OFF_5L EQU H'FF' ; Disabled + +_CP7_ON_5L EQU H'7F' ; Enabled +_CP7_OFF_5L EQU H'FF' ; Disabled + +;----- CONFIG5H Options -------------------------------------------------- +_CPB_ON_5H EQU H'BF' ; Enabled +_CPB_OFF_5H EQU H'FF' ; Disabled + +_CPD_ON_5H EQU H'7F' ; Enabled +_CPD_OFF_5H EQU H'FF' ; Disabled + +;----- CONFIG6L Options -------------------------------------------------- +_WRT0_ON_6L EQU H'FE' ; Enabled +_WRT0_OFF_6L EQU H'FF' ; Disabled + +_WRT1_ON_6L EQU H'FD' ; Enabled +_WRT1_OFF_6L EQU H'FF' ; Disabled + +_WRT2_ON_6L EQU H'FB' ; Enabled +_WRT2_OFF_6L EQU H'FF' ; Disabled + +_WRT3_ON_6L EQU H'F7' ; Enabled +_WRT3_OFF_6L EQU H'FF' ; Disabled + +_WRT4_ON_6L EQU H'EF' ; Enabled +_WRT4_OFF_6L EQU H'FF' ; Disabled + +_WRT5_ON_6L EQU H'DF' ; Enabled +_WRT5_OFF_6L EQU H'FF' ; Disabled + +_WRT6_ON_6L EQU H'BF' ; Enabled +_WRT6_OFF_6L EQU H'FF' ; Disabled + +_WRT7_ON_6L EQU H'7F' ; Enabled +_WRT7_OFF_6L EQU H'FF' ; Disabled + +;----- CONFIG6H Options -------------------------------------------------- +_WRTC_ON_6H EQU H'DF' ; Enabled +_WRTC_OFF_6H EQU H'FF' ; Disabled + +_WRTB_ON_6H EQU H'BF' ; Enabled +_WRTB_OFF_6H EQU H'FF' ; Disabled + +_WRTD_ON_6H EQU H'7F' ; Enabled +_WRTD_OFF_6H EQU H'FF' ; Disabled + +;----- CONFIG7L Options -------------------------------------------------- +_EBRT0_ON_7L EQU H'FE' ; Enabled +_EBRT0_OFF_7L EQU H'FF' ; Disabled + +_EBRT1_ON_7L EQU H'FD' ; Enabled +_EBRT1_OFF_7L EQU H'FF' ; Disabled + +_EBRT2_ON_7L EQU H'FB' ; Enabled +_EBRT2_OFF_7L EQU H'FF' ; Disabled + +_EBRT3_ON_7L EQU H'F7' ; Enabled +_EBRT3_OFF_7L EQU H'FF' ; Disabled + +_EBRT4_ON_7L EQU H'EF' ; Enabled +_EBRT4_OFF_7L EQU H'FF' ; Disabled + +_EBRT5_ON_7L EQU H'DF' ; Enabled +_EBRT5_OFF_7L EQU H'FF' ; Disabled + +_EBRT6_ON_7L EQU H'BF' ; Enabled +_EBRT6_OFF_7L EQU H'FF' ; Disabled + +_EBRT7_ON_7L EQU H'7F' ; Enabled +_EBRT7_OFF_7L EQU H'FF' ; Disabled + +;----- CONFIG7H Options -------------------------------------------------- +_EBRTB_ON_7H EQU H'BF' ; Enabled +_EBRTB_OFF_7H EQU H'FF' ; Disabled + + +;----- DEVID Equates -------------------------------------------------- +_DEVID1 EQU H'3FFFFE' +_DEVID2 EQU H'3FFFFF' + +;----- IDLOC Equates -------------------------------------------------- +_IDLOC0 EQU H'200000' +_IDLOC1 EQU H'200001' +_IDLOC2 EQU H'200002' +_IDLOC3 EQU H'200003' +_IDLOC4 EQU H'200004' +_IDLOC5 EQU H'200005' +_IDLOC6 EQU H'200006' +_IDLOC7 EQU H'200007' + + LIST
--- a/src/adc_lightsensor.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/adc_lightsensor.asm Mon May 24 18:41:51 2021 +0200 @@ -25,6 +25,7 @@ ; ; bank safe ; + global wait_adc wait_adc: movwf ADCON0 ; select ADC channel nop ; wait a short moment @@ -278,11 +279,12 @@ movlw b'00011101' ; power on ADC, select AN7 rcall wait_adc MOVII ADRESL,ambient_light - bcf ADCON0,0 ; power off ADC + bcf ADCON0,0 ; power off ADC + btfsc ambient_light+1,7 ; result negative? + return ; Yes, skip this measurement ; ambient_light:2 is between 4096 (direct sunlight) and about 200 (darkness) ; first: divide by 16 - movlw .4 ; divide by 2^4 = 16 get_ambient_level1_loop: bcf STATUS,C ; clear carry @@ -299,7 +301,7 @@ movwf ambient_light+0 ; YES - avoid ADC clipping incfsz ambient_light+0,W ; = 255 ? - bra get_ambient_level2 ; NO - continue + bra get_ambient_level2 ; NO - continue movlw .254 movwf ambient_light+0 ; avoid ADC clipping
--- a/src/compass_ops.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/compass_ops.asm Mon May 24 18:41:51 2021 +0200 @@ -235,7 +235,7 @@ call request_speed_fastest ; request CPU speed change to fastest speed - movlw .7 ; initialize gain + movlw .5 ; initialize gain movff WREG,opt_compass_gain ; ... movlw .60 ; initialize timeout to 60 seconds
--- a/src/configuration.inc Sat Nov 21 17:46:29 2020 +0100 +++ b/src/configuration.inc Mon May 24 18:41:51 2021 +0200 @@ -24,8 +24,8 @@ #endif #define fw_version_major 0x03 -#define fw_version_minor 0x0E -#define fw_version_beta 0x01 +#define fw_version_minor 0x0F +#define fw_version_beta 0x00 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -42,11 +42,11 @@ ; #endif -#define firmware_creation_year 0x14 -#define firmware_creation_month 0x0A -#define firmware_creation_day 0x1C +#define firmware_creation_year 0x15 +#define firmware_creation_month 0x05 +#define firmware_creation_day 0x15 -#define firmware_expire_year 0x16 +#define firmware_expire_year 0x17 #define firmware_expire_month 0x0A #define firmware_expire_day 0x1C @@ -64,7 +64,7 @@ ; 122.880 max. available #endif -#define _hwos_tech_2_TR +#define _hwos_tech_3_cR #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -80,7 +80,7 @@ #endif #define _language_1 en -#define _language_2 none +#define _language_2 de #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -146,7 +146,7 @@ #define _gas_contingency #define NOT_INCLUDED_external_sensor #define NOT_INCLUDED_cave_mode -#define NOT_INCLUDED_big_divemenu +#define _big_divemenu #define _firmware_recovery #define NOT_INCLUDED_min_depth_option #define NOT_INCLUDED_screendump @@ -166,7 +166,7 @@ #define _gas_contingency #define NOT_INCLUDED_external_sensor #define _cave_mode -#define NOT_INCLUDED_big_divemenu +#define _big_divemenu #define _firmware_recovery #define NOT_INCLUDED_min_depth_option #define NOT_INCLUDED_screendump @@ -186,7 +186,7 @@ #define _external_sensor #define _gas_contingency #define NOT_INCLUDED_cave_mode -#define NOT_INCLUDED_big_divemenu +#define _big_divemenu #define _firmware_recovery #define NOT_INCLUDED_min_depth_option #define _screendump @@ -206,7 +206,7 @@ #define _external_sensor #define _gas_contingency #define _cave_mode -#define NOT_INCLUDED_big_divemenu +#define _big_divemenu #define _firmware_recovery #define NOT_INCLUDED_min_depth_option #define NOT_INCLUDED_screendump @@ -226,7 +226,7 @@ #define _rx_update #define NOT_INCLUDED_external_sensor #define NOT_INCLUDED_cave_mode -#define NOT_INCLUDED_big_divemenu +#define _big_divemenu #define _firmware_recovery #define NOT_INCLUDED_min_depth_option #define NOT_INCLUDED_screendump
--- a/src/divemenu_tree.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/divemenu_tree.asm Mon May 24 18:41:51 2021 +0200 @@ -90,7 +90,7 @@ ;bra main_divemenu_OC_cave ; YES - use version with cave mode entry main_divemenu_OC_cave: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tMainMenu, .6 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist MENU_CALL tDivemenu_ResetAvg, do_reset_average MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf @@ -101,7 +101,7 @@ ENDIF ; _cave_mode main_divemenu_OC_nocave: - MENU_BEGIN_DIVE .5 + MENU_BEGIN_DIVE tMainMenu, .5 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist MENU_CALL tDivemenu_ResetAvg, do_reset_average MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf @@ -117,7 +117,7 @@ btfsc FLAG_pscr_mode ; in pSCR mode? bra main_divemenu_pscr ; YES - show pSCR menu - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tMainMenu, .6 MENU_CALL tDiveBailout, do_divemode_gaslist_bail MENU_CALL tDivemenu_Setpoint, do_divemode_splist MENU_CALL tDivemenu_Diluent, do_divemode_gaslist @@ -136,7 +136,7 @@ ENDIF ; _external_sensor main_divemenu_pscr_no_sensors: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tMainMenu, .6 MENU_CALL tDiveBailout, do_divemode_gaslist_bail MENU_CALL tDivemenu_Premix, do_divemode_gaslist MENU_CALL tBackToLoop, do_switch_sp_calc @@ -147,7 +147,7 @@ IFDEF _external_sensor main_divemenu_pscr_sensors: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tMainMenu, .6 MENU_CALL tDiveBailout, do_divemode_gaslist_bail MENU_CALL tCCRModeSensor, do_divemode_setpoint_pscr MENU_CALL tDivemenu_Premix, do_divemode_gaslist @@ -214,7 +214,7 @@ movlw .1 ; set to first option in dive mode menu movwf menu_pos_cur ; ... - MENU_BEGIN_DIVE .2 + MENU_BEGIN_DIVE tDivemenu_ToggleGF, .2 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf_toggle MENU_CALL tExit, do_exit_divemode_menu MENU_END @@ -254,7 +254,7 @@ movlw .1 ; set to first option in dive mode menu movwf menu_pos_cur ; ... - MENU_BEGIN_DIVE .3 + MENU_BEGIN_DIVE tDivemenu_Marker, .3 MENU_CALL tDivemenu_ResetAvg, do_reset_average MENU_CALL tDivemenu_Marker, do_set_marker MENU_CALL tBack, do_return_main_divemenu ; return to main menu @@ -303,7 +303,7 @@ do_divemode_gaslist_1: movwf menu_pos_cur ; position cursor to best gas/dil (or first option if none avail) - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tDivemenu_Gaslist, .6 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas @@ -367,7 +367,7 @@ bcf better_gas_hint ; do not mark the best gas/diluent bcf color_code_gases ; do not color-code the gases/diluents by their ppO2 - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tDivemenu_LostGas, .6 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost @@ -473,7 +473,7 @@ IFDEF _helium - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tGas6, .6 MENU_OPT_INCS tO2Plus, oGas6O2 MENU_OPT_DECS tO2Minus, oGas6O2 MENU_OPT_INCS tHePlus, oGas6He @@ -482,7 +482,7 @@ MENU_CALL tExit, do_exit_divemode_menu MENU_END ELSE - MENU_BEGIN_DIVE .4 + MENU_BEGIN_DIVE tGas6, .4 MENU_OPT_INCS tO2Plus, oGas6O2 MENU_OPT_DECS tO2Minus, oGas6O2 MENU_DYNAMIC dyn_show_gas6, do_gas6_switch @@ -541,7 +541,7 @@ ENDIF ; _external_sensor do_divemode_splist_no_sensor: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tFixedSetpoints, .6 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp @@ -554,7 +554,7 @@ IFDEF _external_sensor do_divemode_splist_sensor: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tFixedSetpoints, .6 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp @@ -642,7 +642,7 @@ movwf menu_pos_cur ; ... do_return_divemode_common: - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tDivemenu_UseSensor,.6 MENU_CALL tDivemenu_UseSensor, do_switch_sensor MENU_CALL tBack, do_divemode_splist MENU_CALL tExit, do_exit_divemode_menu @@ -655,7 +655,7 @@ movlw .1 movwf menu_pos_cur ; set to 1st option: use calculated ppO2 - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tDivemenu_UseSensor,.6 MENU_CALL tCalculated, do_switch_sp_calc MENU_CALL tDivemenu_UseSensor, do_switch_sensor MENU_CALL tExit, do_exit_divemode_menu @@ -735,7 +735,7 @@ movwf active_customview ; set custom view number call dive_customview_callup ; draw custom view - MENU_BEGIN_DIVE .6 + MENU_BEGIN_DIVE tCaveMode, .6 MENU_DYNAMIC dyn_waypoint_set, do_waypoint_set ; 1 MENU_DYNAMIC dyn_turndive_toggle, do_turndive_toggle ; 2 MENU_CALL tDivemenu_off_on, do_cavemode_toggle ; 3
--- a/src/divemode.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/divemode.asm Mon May 24 18:41:51 2021 +0200 @@ -233,7 +233,29 @@ ; Dive Mode Mail Loop ; diveloop_loop: - btfsc trigger_full_second ; new 1/1 second? + btfss trigger_quarter_second ; new 1/4 second? + bra diveloop_loop_0 ; No - continue + + ;---- tasks any new 1/4 second ----- + bcf trigger_quarter_second ; YES - clear flag + + movlw .4 ; 62,5ms * 4 = 1/4 second + movff WREG,isr_tmr7_helper ; to make sure at least 1/4 will pass before trigger_quarter_second is re-set + + btfss press_sensor_type ; New sensor found? + bra diveloop_loop_0 ; No - continue + + ; Handle new pressure sensor every 1/4 second + btfsc ms5837_state ; =0: result of temperature is in the ADC + bra diveloop_loop_quarter_2 + call I2C_get_temp_val_MS5837 ; (Will set ms5837_state) + bra diveloop_loop_0 ; Done. +diveloop_loop_quarter_2: + call I2C_get_press_val_MS5837 ; (Will clear ms5837_state) + ;---- tasks any new 1/4 second done ----- + +diveloop_loop_0: + btfsc trigger_full_second ; new 1/1 second? bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second btfsc trigger_half_second ; NO - new 1/2 second? bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second @@ -465,7 +487,7 @@ diveloop_loop_12: - bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) + bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) btfsc request_next_custview ; shall show next custom view? call dive_customview_toggle ; YES - show next custom view
--- a/src/hwos.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/hwos.asm Mon May 24 18:41:51 2021 +0200 @@ -44,11 +44,13 @@ ;---- Flags - Hardware Descriptors HW_descriptor res 1 ; OSTC - model descriptor (cleared & rebuilt in restart) -HW_variants res 1 ; OSTC - model variants (NOT cleared in restart) - +HW_variants res 1 ; OSTC - model variants (NOT cleared in restart) +HW_variants2 res 1 ; OSTC - more model variants (NOT cleared in restart) + ;---- Flags - Hardware States HW_flags_state1 res 1 ; hardware - states 1 HW_flags_state2 res 1 ; hardware - states 2 +HW_flags_state3 res 1 ; hardware - states 3 ;--- Flags - Operating System OS_flags_persist res 1 ; system - persistent settings (NOT cleared in restart) @@ -107,17 +109,19 @@ -; 40 byte user data +; 44 byte user data ; 32 byte tmp data placed by C compiler ; 20 byte variables placed by math library ; == -; 92 byte used, 4 byte free (96 byte total available) +; 96 byte used, 0 byte free (96 byte total available) global HW_descriptor global HW_variants + global HW_variants2 global HW_flags_state1 global HW_flags_state2 + global HW_flags_state3 global OS_flags_persist global OS_flags_ISR1 global OS_flags_ISR2 @@ -173,7 +177,7 @@ movwf cpu_speed_request ; store CPU shall run with normal speed movwf cpu_speed_state ; store CPU does run with normal speed - bcf RCON,SBOREN ; brown-out off (not needed here, is handled in bootloader) + ;bcf RCON,SBOREN ; brown-out off (not needed here, is handled in bootloader) bcf RCON,IPEN ; priority interrupts off banksel WDTCON @@ -366,7 +370,7 @@ movlw b'00101000' ; set up I2C to master mode movwf SSP1CON1 ; ... clrf SSP1CON2 ; ... - movlw 0x9C ; select speed 100kHz @ 64MHz Fosc + movlw i2c_speed_value movwf SSP1ADD ; ... @@ -441,8 +445,6 @@ movwf PIE1 ; ... movlw b'00000010' ; enable timer 3 IRQ movwf PIE2 ; ... - movlw b'00000000' ; enable timer 5 IRQ - movwf PIE5 ; ... movlw b'00000001' ; enable RTCC IRQ movwf PIE3 ; ... movlw b'00001001' ; enable timer 7 and timer 4 IRQ
--- a/src/hwos.inc Sat Nov 21 17:46:29 2020 +0100 +++ b/src/hwos.inc Mon May 24 18:41:51 2021 +0200 @@ -12,7 +12,7 @@ ; ---- Hardware Configuration - LIST P=18F87K22 ; compiler settings, if changed change also: Configure -> SelectDevice in MPLAB + LIST P=18F87K22 ; compiler settings, if changed change also: Configure -> SelectDevice in MPLAB #include "p18f87k22.inc" ; processor definitions #include "ports.inc" ; port map definitions @@ -70,6 +70,8 @@ #DEFINE speed_is_normal cpu_speed_state,1 ; =1: CPU is running at normal speed #DEFINE speed_is_fastest cpu_speed_state,2 ; =1: CPU is running at fastest speed +; ---- I2C speed +#DEFINE i2c_speed_value 0x27 ;0x9C = 100kHz @ 64MHz Fosc, 0x27 = 100kHz @ 16MHz Fosc ; ---- Divemode Custom View Indexes - Attention: these numbers need to be in line with the jump tables in customview.asm! #DEFINE index_blank .0 ; blank view @@ -444,7 +446,7 @@ #DEFINE timebase_0sec timebase,0 ; counting timebase, 1/2 sec bit #DEFINE timebase_1sec timebase,1 ; counting timebase, 1 sec bit #DEFINE timebase_2sec timebase,2 ; counting timebase, 2 sec bit -#DEFINE trigger_quarter_second timebase,3 ; =1: a new 1/4 second has begun (not synced with the other time flags, not generated while block_sensor_interrupt is set) +#DEFINE trigger_quarter_second timebase,3 ; =1: a new 1/4 second has begun (not synced with the other time flags) #DEFINE trigger_half_second timebase,4 ; =1: a new 1/2 second has begun #DEFINE trigger_full_second timebase,5 ; =1: a new 1/1 second has begun #DEFINE trigger_full_minute timebase,6 ; =1: a new minute has begun @@ -484,6 +486,15 @@ #DEFINE analog_switches HW_variants,6 ; =1: analog switches available #DEFINE battery_is_36v HW_variants,7 ; =1: a 3.6 Volt battery is detected + ;---- Hardware - OSTC Model Variants2 (stored in access RAM, NOT cleared in restart) +#DEFINE press_sensor_type HW_variants2,0 ; =1: pressure sensor MS5837, =0: Pressure sensor MS5541 +; HW_variants2,1 ; --- unused +; HW_variants2,2 ; --- unused +; HW_variants2,3 ; --- unused +; HW_variants2,4 ; --- unused +; HW_variants2,5 ; --- unused +; HW_variants2,6 ; --- unused +; HW_variants2,7 ; --- unused ;---- Hardware - States 1 (stored in access RAM, cleared on restart) #DEFINE analog_sw1_pressed HW_flags_state1,0 ; =1: analog switch 1 pressed @@ -503,9 +514,18 @@ #DEFINE battery_low_condition HW_flags_state2,4 ; =1: low battery condition detected #DEFINE flash_wrap_around HW_flags_state2,5 ; =1: address wrap-around control / signalling #DEFINE flash_wait HW_flags_state2,6 ; =1: wait for flash write operation to complete -; HW_flags_state2,7 ; --- unused +#DEFINE i2c_busy_temperature HW_flags_state2,7 ; =1: Currently updating temperature from MS5837 - + ;---- Hardware - States 3 (stored in access RAM, NOT cleared on restart) +#DEFINE ms5837_state HW_flags_state3,0 ; =1: result of pressure is in the ADC +#DEFINE i2c_busy_pressure HW_flags_state3,1 ; =1: Currently updating pressure from MS5837 +; HW_flags_state3,2 ; --- unused +; HW_flags_state3,3 ; --- unused +; HW_flags_state3,4 ; --- unused +; HW_flags_state3,5 ; --- unused +; HW_flags_state3,6 ; --- unused +; HW_flags_state3,7 ; --- unused + ;---- Operating System - persistent Settings (stored in access RAM, NOT cleared in restart) #DEFINE sensor1_calibrated_ok OS_flags_persist,0 ; =1: sensor 1 calibration ok #DEFINE sensor2_calibrated_ok OS_flags_persist,1 ; =1: sensor 2 calibration ok @@ -840,13 +860,13 @@ TSTOSS macro opt_reg ; TeST Option Skip next instruction if Set (not zero) movff opt_reg,EEDATA ; Attention: destroys EEDATA! - tstfsz EEDATA,A ; Attention: must be followed by a plain machine + tstfsz EEDATA ; Attention: must be followed by a plain machine bra $+4 ; command, do not let follow a macro! endm ; TSTOSC macro opt_reg ; TeST Option Skip next instruction if Clear (zero) movff opt_reg,EEDATA ; Attention: destroys EEDATA! - tstfsz EEDATA,A ; Attention: must be followed by a plain machine + tstfsz EEDATA ; Attention: must be followed by a plain machine endm ; command, do not let follow a macro! @@ -1013,9 +1033,11 @@ extern HW_descriptor extern HW_variants + extern HW_variants2 extern HW_flags_state1 extern HW_flags_state2 + extern HW_flags_state3 extern OS_flags_persist extern OS_flags_ISR1 @@ -1116,18 +1138,18 @@ dMSB res 1 ; pressure sensor interface, MSB dbuffer res 1 ; pressure sensor interface, RX/TX buffer -C1 res 2 ; decoded calibration data -C2 res 2 ; decoded calibration data -C3 res 2 ; decoded calibration data -C4 res 2 ; decoded calibration data, here C4-250 -C5 res 2 ; decoded calibration data, here reference temperature UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) -C6 res 2 ; decoded calibration data -D1 res 2 ; raw pressure -D2 res 2 ; raw temperature -xdT res 2 +C1 res 2 ; decoded calibration data +C2 res 2 ; decoded calibration data +C3 res 2 ; decoded calibration data +C4 res 2 ; decoded calibration data, here C4-250 +C5 res 2 ; decoded calibration data, here reference temperature UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) +C6 res 2 ; decoded calibration data +D1 res 3 ; raw pressure +D2 res 3 ; raw temperature +xdT res 3 xdT2 res 2 -OFF res 2 -SENS res 2 +OFF res 4 +SENS res 4 temperature_cur res 2 ; current temperature temperature_min res 2 ; minimum temperature (operated by divemode.asm) @@ -1135,7 +1157,7 @@ temperature_last res 2 ; internal register used for detecting changes pressure_abs res 2 ; current absolute pressure -pressure_abs_avg res 2 ; internal register used for averaging +pressure_abs_avg res 3 ; internal register used for averaging pressure_abs_last res 2 ; internal register used for detecting pressure changes pressure_abs_sampled res 2 ; sampled surface pressure, sampled in sleep mode every 15 minutes @@ -1147,9 +1169,10 @@ pressure_rel_sim res 2 ; simulated relative pressure (simulator mode) ;---- Data for ISR Math Subroutines -isr_xA res 2 ; multiplicand 1 -isr_xB res 2 ; multiplicand 2 -isr_xC res 4 ; resulting product +isr_xA res 4 ; multiplicand 1 +isr_xB res 3 ; multiplicand 2 +isr_xC res 7 ; resulting product +isr_math_loop res 1 ; loop counter ;---- Display Brightness ambient_light res 2 ; ambient light level @@ -1190,8 +1213,9 @@ ENDIF debounce_counter res 1 ; multiples of 16ms - -; 144 byte used, 16 byte free +isr_tmr7_helper res 1 ; used for 1/4 second trigger + +; 158 byte used, 2 byte free ;----------------------------------------------------------------------------- @@ -1567,7 +1591,11 @@ time_last_2nd res 2 ; last pressure reading time in seconds | ENDIF -; 156 byte used, 100 byte free +i2c_error_vault res 2 ; Store last used device ID and data byte +D1_buffer res 3 ; Buffer of D1 (Sensor raw data) +D2_buffer res 3 ; Buffer of D2 (Sensor raw data) + +; 156 byte used, 93 byte free ;-----------------------------------------------------------------------------
--- a/src/i2c.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/i2c.asm Mon May 24 18:41:51 2021 +0200 @@ -37,6 +37,16 @@ ; ----------- ; RX Circuity read address (8-Bit): 0x51 ; RX Circuity write address (8-Bit): 0x50 +; +; Battery gauge +; ------------- +; LTC2942 read address (8-Bit): 0xC9 +; LTC2942 write address (8-Bit): 0xC8 +; +; Alternative pressure sensor +; ----------- +; MS5837 read address (8-Bit): 0xED +; MS5837 write address (8-Bit): 0xEC ; ; @@ -49,21 +59,13 @@ #include "wait.inc" #include "math.inc" #include "eeprom_rs232.inc" - + ;============================================================================= i2c CODE ;============================================================================= -;----------------------------------------------------------------------------- -; Helper Function - send 1 Byte, wait for end of transmission and check ackn -; -I2C_TX: - movwf SSP1BUF ; put byte to be sent into TX buffer - rcall WaitMSSP ; wait for TX to complete - bra I2C_Check_ACK ; check for acknowledge by receiver and return - ;----------------------------------------------------------------------------- ; Helper Function - get two Bytes and divide hi:lo/16 (signed) @@ -117,10 +119,11 @@ bra I2C_RX_accelerometer_compass1 ; YES ;bra I2C_RX_accelerometer_compass0 ; NO - compass0 then -I2C_RX_accelerometer_compass0: +;I2C_RX_accelerometer_compass0: bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x38 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x00 ; ?? rcall I2C_TX ; send byte @@ -178,13 +181,15 @@ incf hi,F ; YES - do it MOVII mpr,accel_DZ ; copy result to accel_DZ bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return I2C_RX_accelerometer_compass1: bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw b'10101000' ; 0x28 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -274,6 +279,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x32 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw b'10101000' ; 0x28 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -286,6 +292,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3A ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x28 ; 0x28 (OUT_X_L_A) rcall I2C_TX ; send byte @@ -320,10 +327,11 @@ bra I2C_RX_compass1 ; YES ;bra I2C_RX_compass0 ; NO - compass 0 then -I2C_RX_compass0: +;I2C_RX_compass0: bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x03 ; ?? rcall I2C_TX ; send byte @@ -395,6 +403,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw b'10001000' ; 0x08 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -440,14 +449,17 @@ movff SSP1BUF,hi ; data byte rcall I2C_TwoBytesRX_div8 ; divide hi, lo by 8 (signed) MOVII mpr,compass_DZ ; copy result - bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; ... and return + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP + return ; done + I2C_RX_compass2: ; compass type 2 bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xE8 ; 0x68 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -492,13 +504,16 @@ ; rcall I2C_TwoBytesRX_div8 ; divide hi, lo by 8 (signed) MOVII mpr,compass_DZ ; copy result bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; ...and return + rcall WaitMSSP + return ; done + I2C_RX_compass3: ; compass type 3 bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xA8 ; 0x28 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -524,6 +539,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3A ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete btfss SSP1CON2,ACKSTAT ; ACK received? @@ -538,6 +554,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x32 ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete btfss SSP1CON2,ACKSTAT ; ACK received? @@ -553,6 +570,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x0F ; ?? rcall I2C_TX ; send byte @@ -579,6 +597,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x00 ; ?? rcall I2C_TX ; send byte @@ -602,6 +621,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x38 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x0E ; XYZ_DATA_CFG rcall I2C_TX ; send byte @@ -633,13 +653,16 @@ movlw b'00110101' ; CTRL_REG1: 160 ms data rate, standby mode, reduced noise mode, active Mode rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done + I2C_init_compass1: bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x9F ; 1F with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -675,7 +698,8 @@ movlw b'00000000' ; CTRL7 Continuous Mode rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ; accelerometer initializes along with magnetic sensor @@ -685,6 +709,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xE0 ; 0x60 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -701,6 +726,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x32 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x9F ; 1F with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -717,7 +743,8 @@ ; movlw b'00000000' ; CTRL_REG5_A ; rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done I2C_init_compass3: @@ -725,6 +752,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xA0 ; 0x20 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -747,6 +775,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3A ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x20 rcall I2C_TX ; send byte @@ -759,8 +788,16 @@ movlw b'11001100' ; CTRL_REG4_A 0x23 rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done +;----------------------------------------------------------------------------- +; Helper Function - send 1 Byte, wait for end of transmission and check ackn +; +I2C_TX: + movwf SSP1BUF ; put byte to be sent into TX buffer + rcall WaitMSSP ; wait for TX to complete + bra I2C_Check_ACK ; check for acknowledge by receiver and return ;----------------------------------------------------------------------------- ; Deactivate Compass / Accelerometer @@ -784,6 +821,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x00 ; ?? rcall I2C_TX ; send byte @@ -801,19 +839,22 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x38 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x2A ; CTRL_REG1 rcall I2C_TX ; send byte movlw b'00000000' ; standby mode rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done I2C_sleep_compass1: bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x20 ; CTRL_REG1 rcall I2C_TX ; send byte @@ -830,7 +871,8 @@ movlw b'00000010' ; data for CTRL_REG7: magnetic sensor power-down mode rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ; accelerometer sleeps with magnetic sensor @@ -840,6 +882,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xE0 ; 0x60 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -858,6 +901,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x32 ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x9F ; 1F with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -866,7 +910,8 @@ movlw b'00000000' ; CTRL_REG1_A 0x20 (all off) rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done I2C_sleep_compass3: @@ -874,6 +919,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3C ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0xA2 ; 0x22 with auto-increment (MSB=1) rcall I2C_TX ; send byte @@ -886,19 +932,22 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x3A ; address + movff WREG,i2c_error_vault+0 ; Store address rcall I2C_TX ; send byte movlw 0x20 rcall I2C_TX ; send byte movlw b'00000000' ; CTRL_REG1_A (100Hz, x,y,z = OFF) 0x20 rcall I2C_TX ; send byte bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- ; Helper Function - wait for TX to complete ; WaitMSSP: + movff SSP1BUF,i2c_error_vault+1 clrf i2c_temp1 ; wait for max 256 loops WaitMSSP_loop: decfsz i2c_temp1,F ; decrement loop counter, timeout? @@ -929,6 +978,8 @@ bcf PIR1,SSP1IF ; clear TX completion flag bsf i2c_error_flag ; set error flag bcf active_reset_ostc_rx ; release reset from RX circuitry +; bcf i2c_busy_temperature +; bcf i2c_busy_pressure return ; done @@ -972,7 +1023,7 @@ movwf SSP1CON1 ; ... movlw b'00000000' ; ... movwf SSP1CON2 ; ... - movlw 0x9C ; ... + movlw i2c_speed_value movwf SSP1ADD ; ... return ; done @@ -1007,7 +1058,8 @@ rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- ; Sleep Gauge IC @@ -1021,7 +1073,8 @@ rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- ; Read Gauge IC - Status Register @@ -1032,11 +1085,18 @@ movlw 0x00 ; point to status register rcall I2C_TX_GAUGE ; send byte to the LT2942 gauge IC rcall I2C_RX_GAUGE ; receive byte from the LT2942 Gauge IC + + bsf SSP1CON2,ACKDT ; set ACKDT flag + bsf SSP1CON2,ACKEN ; master NOT acknowledge + rcall WaitMSSP ; wait for TX to complete + bcf SSP1CON2,ACKDT ; reset ACKDT flag + movff SSP1BUF,WREG ; copy received byte to WREG btfss WREG,7 ; 2942 found? bsf battery_gauge_available ; YES - set flag bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- @@ -1053,9 +1113,14 @@ bsf SSP1CON2,RCEN ; enable receive mode rcall WaitMSSP ; wait for TX to complete movff SSP1BUF,xA+0 ; copy received byte to xA+0 + bsf SSP1CON2,ACKDT ; set ACKDT flag + bsf SSP1CON2,ACKEN ; master NOT acknowledge + rcall WaitMSSP ; wait for TX to complete + bcf SSP1CON2,ACKDT ; reset ACKDT flag + bsf SSP1CON2,PEN ; stop condition rcall WaitMSSP ; wait for TX to complete - + ; convert voltage from raw value to Volt MOVLI .6000,xB ; load conversion multiplicand into xB call mult16x16 ; xC = xA * xB -> multiply raw value in xA with conversion multiplicand @@ -1074,14 +1139,19 @@ global lt2942_get_temperature lt2942_get_temperature: ; read battery temperature movlw 0x0C ; point to temperature register - call I2C_TX_GAUGE ; send byte to the LT2942 gauge IC - call I2C_RX_GAUGE ; receive byte from the LT2942 Gauge IC + rcall I2C_TX_GAUGE ; send byte to the LT2942 gauge IC + rcall I2C_RX_GAUGE ; receive byte from the LT2942 Gauge IC bsf SSP1CON2,ACKEN ; master acknowledge rcall WaitMSSP ; wait for TX to complete movff SSP1BUF,xA+1 ; store raw temperature, high byte bsf SSP1CON2,RCEN ; enable receive mode rcall WaitMSSP ; wait for TX to complete movff SSP1BUF,xA+0 ; store raw temperature, low byte + bsf SSP1CON2,ACKDT ; set ACKDT flag + bsf SSP1CON2,ACKEN ; master NOT acknowledge + rcall WaitMSSP ; wait for TX to complete + bcf SSP1CON2,ACKDT ; reset ACKDT flag + bsf SSP1CON2,PEN ; stop condition rcall WaitMSSP ; wait for TX to complete @@ -1147,12 +1217,16 @@ bsf SSP1CON2,RCEN ; enable receive mode rcall WaitMSSP ; wait for TX to complete movff SSP1BUF,sub_a+0 ; copy received byte to sub_a+0 + bsf SSP1CON2,ACKDT ; set ACKDT flag + bsf SSP1CON2,ACKEN ; master NOT acknowledge + rcall WaitMSSP ; wait for TX to complete + bcf SSP1CON2,ACKDT ; reset ACKDT flag + bsf SSP1CON2,PEN ; stop condition rcall WaitMSSP ; wait for TX to complete btfsc gauge_status_byte,0 ; UVLO event ? rcall lt2942_init_again ; YES - do an re-initialization - MOVII sub_a,battery_accumulated_charge ; save raw value ; Compute batt_percent = (charge - battery_offset) / 365 @@ -1182,7 +1256,8 @@ rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- @@ -1199,7 +1274,8 @@ rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done ;----------------------------------------------------------------------------- @@ -1209,7 +1285,8 @@ movwf i2c_temp2 ; save data byte to be sent bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete - movlw b'11001000' ; address byte + Write bit + movlw 0xC8 ; address byte + Write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver @@ -1221,9 +1298,10 @@ ; Helper Function - receive 1 Byte from the LT2942 Gauge IC ; I2C_RX_GAUGE: - bsf SSP1CON2,SEN ; start condition + bsf SSP1CON2,RSEN ; repeated start condition rcall WaitMSSP ; wait for TX to complete - movlw b'11001001' ; address byte + Read bit + movlw 0xC9 ; address byte + Read bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver @@ -1280,6 +1358,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x50 ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete btfss SSP1CON2,ACKSTAT ; ACK received? @@ -1290,7 +1369,6 @@ return ; NO - done WAITMS .1 ; wait 1 ms - bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x50 ; address byte + write bit @@ -1327,7 +1405,7 @@ bcf SSP1CON2,ACKDT ; reset ACKDT flag bsf SSP1CON2,PEN ; stop condition rcall WaitMSSP ; wait for TX to complete - + ; wait for TR module becoming ready movff rx_firmware_cur_minor,i2c_temp1 ; copy minor firmware version to bank common movlw .147 ; code for not ready, minor @@ -1356,6 +1434,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x50 ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver @@ -1396,7 +1475,9 @@ rcall WaitMSSP ; wait for TX to complete bcf SSP1CON2,ACKDT ; reset ACKDT flag bsf SSP1CON2,PEN ; stop condition - bra WaitMSSP ; wait for TX to complete and return + rcall WaitMSSP ; wait for TX to complete + return ; done + ;----------------------------------------------------------------------------- @@ -1415,6 +1496,7 @@ bsf SSP1CON2,SEN ; start condition rcall WaitMSSP ; wait for TX to complete movlw 0x50 ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address movwf SSP1BUF ; control byte rcall WaitMSSP ; wait for TX to complete rcall I2C_Check_ACK ; check for acknowledge by receiver @@ -1489,7 +1571,224 @@ ENDIF ; _rx_update ENDIF ; _rx_functions - + ;----------------------------------------------------------------------------- +; Probe for MS5837 sensor +; + global I2C_probe_pressure_sensor ; Do not call from ISR! +I2C_probe_pressure_sensor: ; Probe the type of sensor, set/clear press_sensor_type + bcf press_sensor_type ; MS5541 as default + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address + movwf SSP1BUF ; control byte + rcall WaitMSSP ; wait for TX to complete + btfss SSP1CON2,ACKSTAT ; ACK received? + bsf press_sensor_type ; MS5837 sensor found + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + return + +;-------------------------------------------------------------------- +; Helper Function - get the calibration parameter from # WREG address +; Do not call from ISR! +I2C_get_calib_parameter: + movwf lo ; store address + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address + rcall I2C_TX ; send byte + movf lo,W ; Point to calibration register + rcall I2C_TX ; send byte + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xED ; address byte + read bit + movff WREG,i2c_error_vault+0 ; Store address + movwf SSP1BUF ; control byte + rcall WaitMSSP ; wait for TX to complete + rcall I2C_Check_ACK ; check for acknowledge by receiver + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception and return + movff SSP1BUF,dMSB ; High byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception + movff SSP1BUF,dLSB ; Low byte +; bsf SSP1CON2,ACKDT ; set ACKDT flag + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete +; bcf SSP1CON2,ACKDT ; reset ACKDT flag + bsf SSP1CON2,PEN ; stop condition + bra WaitMSSP ; wait for TX to complete (And return) + + + global I2C_get_calib_MS5837 ; Do not call from ISR! +I2C_get_calib_MS5837: + banksel common + ; first, send a reset + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address + rcall I2C_TX ; send byte + movlw 0x1E + rcall I2C_TX ; send byte + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + WAITMS .5 ; 2.8ms according to datasheet + + movlw 0xA2 ; Point to C1 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C1+0 ; store calib + movff dMSB,C1+1 ; store calib + movlw 0xA4 ; Point to C2 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C2+0 ; store calib + movff dMSB,C2+1 ; store calib + + movlw 0xA6 ; Point to C3 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C3+0 ; store calib + movff dMSB,C3+1 ; store calib + + movlw 0xA8 ; Point to C4 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C4+0 ; store calib + movff dMSB,C4+1 ; store calib + + movlw 0xAA ; Point to C5 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C5+0 ; store calib + movff dMSB,C5+1 ; store calib + + movlw 0xAC ; Point to C6 + rcall I2C_get_calib_parameter ; returns calibration value in lo and hi + movff dLSB,C6+0 ; store calib + movff dMSB,C6+1 ; store calib + + return + + global I2C_get_press_val_MS5837 +I2C_get_press_val_MS5837: + bsf i2c_busy_pressure ; reading new pressure + + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address + rcall I2C_TX ; send byte + movlw 0x00 ; command byte (0x00, read ADC) + rcall I2C_TX ; send byte + + bsf SSP1CON2,RSEN ; repeated start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xED ; address byte + read bit + movff WREG,i2c_error_vault+0 ; Store address + movwf SSP1BUF ; control byte + rcall WaitMSSP ; wait for TX to complete + rcall I2C_Check_ACK ; check for acknowledge by receiver + + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception and return + movff SSP1BUF,D1_buffer+2 ; Upper byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception + movff SSP1BUF,D1_buffer+1 ; high byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception + movff SSP1BUF,D1_buffer+0 ; Low byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + + ; Start temperature measurement + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + rcall I2C_TX ; send byte + movlw 0x58 ; OSR=4096, type=D2 + rcall I2C_TX ; send byte + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + bcf ms5837_state ; =0: result of temperature will be in the ADC + bcf i2c_busy_pressure ; reading new pressure + return + + global I2C_get_temp_val_MS5837 +I2C_get_temp_val_MS5837: + bsf i2c_busy_temperature ; reading new temperature + + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + movff WREG,i2c_error_vault+0 ; Store address + rcall I2C_TX ; send byte + movlw 0x00 ; command byte (0x00, read ADC) + rcall I2C_TX ; send byte + + bsf SSP1CON2,RSEN ; repeated start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xED ; address byte + read bit + movff WREG,i2c_error_vault+0 ; Store address + movwf SSP1BUF ; control byte + rcall WaitMSSP ; wait for TX to complete + rcall I2C_Check_ACK ; check for acknowledge by receiver + + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception and return + movff SSP1BUF,D2_buffer+2 ; Upper byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception + movff SSP1BUF,D2_buffer+1 ; high byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,RCEN ; enable receive mode + rcall WaitMSSP ; wait for reception + movff SSP1BUF,D2_buffer+0 ; Low byte + bsf SSP1CON2,ACKEN ; master acknowledge + rcall WaitMSSP ; wait for TX to complete + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + + ; Start pressure measurement + bsf SSP1CON2,SEN ; start condition + rcall WaitMSSP ; wait for TX to complete + movlw 0xEC ; address byte + write bit + rcall I2C_TX ; send byte + movlw 0x48 ; OSR=4096, type=D1 + rcall I2C_TX ; send byte + bsf SSP1CON2,PEN ; stop condition + rcall WaitMSSP ; wait for TX to complete + bsf ms5837_state ; =0: result of pressure will be in the ADC + bcf i2c_busy_temperature ; reading new temperature + return + + +;----------------------------------------------------------------------------- +; I2C Bus error checker +; + global check_i2c_error + extern TFT_message_i2c_error +check_i2c_error: + btfss i2c_error_flag + return + incf message_counter,F ; increase message counter + goto TFT_message_i2c_error ; show message for battery low (battery percent) and return + +;----------------------------------------------------------------------------- END
--- a/src/i2c.inc Sat Nov 21 17:46:29 2020 +0100 +++ b/src/i2c.inc Mon May 24 18:41:51 2021 +0200 @@ -34,4 +34,10 @@ IFDEF _compass extern I2C_RX_compass - ENDIF \ No newline at end of file + ENDIF + + extern I2C_probe_pressure_sensor ; Probe the type of sensor, set/clear press_sensor_type + extern I2C_get_calib_MS5837 ; Read C1 to C6 + extern I2C_get_press_val_MS5837 + extern I2C_get_temp_val_MS5837 + extern check_i2c_error \ No newline at end of file
--- a/src/isr.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/isr.asm Mon May 24 18:41:51 2021 +0200 @@ -323,6 +323,15 @@ movlw .248 ; reload timer 7, high byte (8x256 ticks -> 62.5 ms) movwf TMR7H ; ... (keep low byte running ) + banksel isr_backup ; back to ISR default bank + decfsz isr_tmr7_helper,F ; decreased every 62,5ms + bra isr_tmr7_0 + movlw .4 ; 62,5ms * 4 = 1/4 second + movwf isr_tmr7_helper + bsf trigger_quarter_second ; set flag (In access RAM) + + +isr_tmr7_0: btfss update_surface_pressure ; shall update the surface pressure? bra isr_tmr7_1 ; NO - skip bcf update_surface_pressure ; YES - clear request flag @@ -390,9 +399,6 @@ ENDIF ; _external_sensor isr_sensor_state2: - btfss sensor_state_counter,0 ; every 1/4 second - bsf trigger_quarter_second ; set flag - btfss speed_is_normal ; CPU running on normal speed? rcall isr_set_speed_to_normal ; NO - set CPU speed to normal @@ -429,15 +435,17 @@ call calculate_compensation ; calculate temperature compensated pressure (27 us) ; build average for pressure - bcf STATUS,C ; clear carry bit - rrcf pressure_abs_avg+1 ; divide by 2 + ;bcf STATUS,C ; clear carry bit - not needed since we don't use the +2 register later + rrcf pressure_abs_avg+2 ; divide by 2 + rrcf pressure_abs_avg+1 ; ... rrcf pressure_abs_avg+0 ; ... - bcf STATUS,C ; clear carry bit - rrcf pressure_abs_avg+1 ; divide by 2, again + ;bcf STATUS,C ; clear carry bit - not needed since we don't use the +2 register later + rrcf pressure_abs_avg+2 ; divide by 2, again + rrcf pressure_abs_avg+1 ; ... rrcf pressure_abs_avg+0 ; ... ; export averaged pressure - MOVII pressure_abs_avg,pressure_abs ; export result + MOVII pressure_abs_avg,pressure_abs ; export result (Which is 16 bit for all depths < 262m) ; build average for temperature bcf STATUS,C ; clear carry bit by default @@ -541,11 +549,13 @@ bra sensor_int_state_exit ; done sensor_int_state1_plus_restart: - CLRI pressure_abs_avg ; clear average register for pressure + clrf pressure_abs_avg+0 ; clear pressure average register + clrf pressure_abs_avg+1 + clrf pressure_abs_avg+2 CLRI temperature_avg ; clear average register for temperature sensor_int_state1: - call get_temperature_value ; state 1: get temperature... + call get_temperature_value ; state 1: get temperature... call get_pressure_start ; ...and start pressure integration bra sensor_int_state_exit @@ -891,7 +901,7 @@ isr_switch_right: bcf INTCON,INT0IE ; disable external interrupt 0 - btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons + btfsc button_hold_down_allowed ; ignore for mechanical push buttons bra isr_switch_right2 btfsc T4CON,TMR4ON ; Timer4 running? bra timer4_restart ; Yes, restart @@ -906,7 +916,7 @@ isr_switch_left: bcf INTCON3,INT1IE ; disable external interrupt 1 - btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons + btfsc button_hold_down_allowed ; ignore for mechanical push buttons bra isr_switch_left2 btfsc T4CON,TMR4ON ; Timer4 running? bra timer4_restart ; Yes, restart @@ -919,7 +929,7 @@ ;bra isr_switch_common ; continue with common part isr_switch_common: - btfss button_hold_down_allowed,A ; ignore for mechanical push buttons + btfss button_hold_down_allowed ; ignore for mechanical push buttons bsf T4CON,TMR4ON ; Start timer 4 btfsc tmr5_preemtion_allowed ; timer 5 preemption allowed?
--- a/src/math.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/math.asm Mon May 24 18:41:51 2021 +0200 @@ -346,6 +346,9 @@ addwfc isr_xC+3,F ; ... return ; done +;============================================================================= +math12 CODE +;============================================================================= ;----------------------------------------------------------------------------- ; Multiply two SIGNED 16 Bit Integers: isr_xC = isr_xA * isr_xB @@ -355,7 +358,7 @@ global isr_signed_mult16x16 isr_signed_mult16x16: ; do an unsigned multiplication first - rcall isr_unsigned_mult16x16 + call isr_unsigned_mult16x16 ; manage sign extension of operand B btfss isr_xB+1,7 ; is B negative ? @@ -364,7 +367,7 @@ subwf isr_xC+2,F ; - ... movf isr_xA+1,W ; - ... subwfb isr_xC+3,F ; - ... -isr_signed_mult_checkA ; manage sign extension of operand B +isr_signed_mult_checkA: ; manage sign extension of operand B btfss isr_xA+1,7 ; is A negative ? return ; NO - done movf isr_xB+0,W ; YES - add -65536 * B @@ -373,6 +376,237 @@ subwfb isr_xC+3,F ; - ... return ; - done +;============================================================================= +math13 CODE +;============================================================================= + +;----------------------------------------------------------------------------- +; Multiply two UNSIGNED 24 Bit Integers: isr_xC = isr_xA * isr_xB +; +; trashes PRODL, PRODH, WREG +; + global isr_unsigned_mult24x24 +isr_unsigned_mult24x24: + call isr_unsigned_mult16x16 ; Do the 16x16 first + clrf isr_xC+4 + clrf isr_xC+5 ; clear upper 16 bit + ; do the remaining three multiplications + movf isr_xA+0,W ; multiply a[0] * b[2] + mulwf isr_xB+2 ; ... + movf PRODL,W ; add cross product to c[4]:c[3]:c[2] + addwf isr_xC+2,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+3,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+4,F ; ... + addwfc isr_xC+5,F ; ... + + movf isr_xA+2,W ; multiply a[2] * b[0] + mulwf isr_xB+0 ; ... + movf PRODL,W ; add cross product to c[4]:c[3]:c[2] + addwf isr_xC+2,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+3,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+4,F ; ... + addwfc isr_xC+5,F ; ... + ; isr_xC[2] done. + + movf isr_xA+2,W ; multiply a[2] * b[1] + mulwf isr_xB+1 ; ... + movf PRODL,W ; add cross product to c[5]:c[4]:c[3] + addwf isr_xC+3,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+4,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+5,F ; ... + + movf isr_xA+1,W ; multiply a[1] * b[2] + mulwf isr_xB+2 ; ... + movf PRODL,W ; add cross product to c[5]:c[4]:c[3] + addwf isr_xC+3,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+4,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+5,F ; ... + ; isr_xC[3] done. + + movf isr_xA+2,W ; multiply a[2] * b[2] + mulwf isr_xB+2 ; ... + movf PRODL,W ; add cross product to c[5]:c[4] + addwf isr_xC+4,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+5,F ; propagate carry + ; isr_xC[4] done. + ; isr_xC[5] done. + + return ; done + +;============================================================================= +math14 CODE +;============================================================================= + +;----------------------------------------------------------------------------- +; Multiply two UNSIGNED Integers (32 and 24 Bit): isr_xC = isr_xA * isr_xB +; +; trashes PRODL, PRODH, WREG +; + global isr_unsigned_mult32x24 +isr_unsigned_mult32x24: + call isr_unsigned_mult24x24 ; Do the 24x24 first + clrf isr_xC+6 ; clear upper 8 bit + ; do the remaining three multiplications + movf isr_xA+3,W ; multiply a[3] * b[0] + mulwf isr_xB+0 ; ... + movf PRODL,W ; add cross product to c[5]:c[4]:c[3] + addwf isr_xC+3,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+4,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+5,F ; ... + addwfc isr_xC+6,F ; ... + ; isr_xC[3] done. + + movf isr_xA+3,W ; multiply a[3] * b[1] + mulwf isr_xB+1 ; ... + movf PRODL,W ; add cross product to c[5]:c[4] + addwf isr_xC+4,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+5,F ; propagate carry + clrf WREG ; ... + addwfc isr_xC+6,F ; ... + ; isr_xC[4] done. + + movf isr_xA+3,W ; multiply a[3] * b[2] + mulwf isr_xB+2 ; ... + movf PRODL,W ; add cross product to c[5]:c[4] + addwf isr_xC+5,F ; ... + movf PRODH,W ; ... + addwfc isr_xC+6,F ; propagate carry + ; isr_xC[5] done. + ; isr_xC[6] done. + return ; done + + +;============================================================================= +math15 CODE +;============================================================================= + +;----------------------------------------------------------------------------- +; Multiply two SIGNED 24 Bit Integers: isr_xC = isr_xA * isr_xB +; +; trashes PRODL, PRODH, WREG +; + global isr_signed_mult24x24 +isr_signed_mult24x24: + ; do an unsigned multiplication first + call isr_unsigned_mult24x24 + + ; manage sign extension of operand B + btfss isr_xB+2,7 ; is B negative ? + bra isr_signed24_mult_checkA ; NO - continue checking operand A + movf isr_xA+0,W ; YES - add -16777216 * A + subwf isr_xC+3,F ; - ... + movf isr_xA+1,W ; - ... + subwfb isr_xC+4,F ; - ... + movf isr_xA+2,W ; - ... + subwfb isr_xC+5,F ; - ... +isr_signed24_mult_checkA: ; manage sign extension of operand B + btfss isr_xA+2,7 ; is A negative ? + return ; NO - done + movf isr_xB+0,W ; YES - add -16777216 * B + subwf isr_xC+3,F ; - ... + movf isr_xB+1,W ; - ... + subwfb isr_xC+4,F ; - ... + movf isr_xB+2,W ; - ... + subwfb isr_xC+5,F ; - ... + return + +;============================================================================= +math16 CODE +;============================================================================= + +;----------------------------------------------------------------------------- +; Divide two UNSIGNED 16 Bit Integers: isr_xC:2 = isr_xA:2 / isr_xB:2 with xA as remainder +; +; trashes WREG +; + global isr_div16x16 +isr_div16x16: + movlw .16 ; process 16 bits ... + movwf isr_math_loop ; ... initialize loop counter + movff isr_xA+0,isr_xC+0 ; copy isr_xA to isr_xC + movff isr_xA+1,isr_xC+1 ; ... + clrf isr_xA+0 ; clear isr_xA, will now be used to hold the remainder + clrf isr_xA+1 ; ... +isr_div16x16_1: + bcf STATUS,C ; clear carry flag to shift in a zero bit + rlcf isr_xC+0,F ; shift left isr_xC + rlcf isr_xC+1,F ; ... shifting MSB out of isr_xC... + rlcf isr_xA+0,F ; ... and into LSB of isr_xA + rlcf isr_xA+1,F ; ... + btfsc STATUS,C ; did the remainder overflow (carry set)? + bra isr_div16x16_2 ; YES - directly generate a result bit = 1 + movf isr_xB+0,W ; NO - compute remainder - divisor = isr_xA - isr_xB, trash result to WREG + subwf isr_xA+0,W ; - ... + movf isr_xB+1,W ; - ... + subwfb isr_xA+1,W ; - ... + btfss STATUS,C ; - remainder < divisor (-> borrow flag set, equals carry flag cleared) ? + bra isr_div16x16_3 ; YES - result bit = 0, keep LSB of isr_xC+0 being 0 +isr_div16x16_2: + bsf isr_xC+0,0 ; NO - result bit = 1, set LSB of isr_xC+0 to 1 + movf isr_xB+0,W ; - subtract divisor from remainder "for real": isr_xA = isr_xA - isr_xB + subwf isr_xA+0,F ; - ... + movf isr_xB+1,W ; - ... + subwfb isr_xA+1,F ; - ... +isr_div16x16_3: + decfsz isr_math_loop,F ; decrement loop counter, all bits done? + bra isr_div16x16_1 ; NO - loop + return ; YES - done + +;============================================================================= +math17 CODE +;============================================================================= + +;----------------------------------------------------------------------------- +; Divide a 32 Bit Integer by a 16 Bit Integer: isr_xC:4 = isr_xC:4 / isr_xB:2 with isr_xA as remainder +; +; trashes WREG +; + global isr_div32x16 +isr_div32x16: + movlw .32 ; process 32 bits ... + movwf isr_math_loop ; ... initialize loop counter + clrf isr_xA+0 ; clear isr_xA, will be used to hold the remainder + clrf isr_xA+1 ; ... +isr_div32x16_1: + bcf STATUS,C ; clear carry flag to shift in a zero bit + rlcf isr_xC+0,F ; shift left isr_xC + rlcf isr_xC+1,F ; ... + rlcf isr_xC+2,F ; ... + rlcf isr_xC+3,F ; ... shifting MSB out of isr_xC... + rlcf isr_xA+0,F ; ... and into LSB of isr_xA + rlcf isr_xA+1,F ; ... + btfsc STATUS,C ; did the remainder overflow (carry set)? + bra isr_div32x16_2 ; YES - directly generate a result bit = 1 + movf isr_xB+0,W ; NO - compute remainder - divisor = isr_xA - isr_xB, trash result to WREG + subwf isr_xA+0,W ; - ... + movf isr_xB+1,W ; - ... + subwfb isr_xA+1,W ; - ... + btfss STATUS,C ; - remainder < divisor (-> borrow flag set, equals carry flag cleared) ? + bra isr_div32x16_3 ; YES - result bit = 0, keep LSB of isr_xC+0 being 0 +isr_div32x16_2: + bsf isr_xC+0,0 ; NO - result bit = 1, set LSB of isr_xC+0 to 1 + movf isr_xB+0,W ; - subtract divisor from remainder "for real": isr_xA = isr_xA - isr_xB + subwf isr_xA+0,F ; - ... + movf isr_xB+1,W ; - ... + subwfb isr_xA+1,F ; - ... +isr_div32x16_3: + decfsz isr_math_loop,F ; decrement loop counter, all bits done? + bra isr_div32x16_1 ; NO - loop + return ; YES - done + + ;----------------------------------------------------------------------------- END \ No newline at end of file
--- a/src/math.inc Sat Nov 21 17:46:29 2020 +0100 +++ b/src/math.inc Mon May 24 18:41:51 2021 +0200 @@ -90,12 +90,31 @@ ; extern isr_unsigned_mult16x16 ; isr_xC = isr_xA * isr_xB ; trashes PRODL, PRODH, WREG - - +;----------------------------------------------------------------------------- +; MULTIPLICATION with UNSIGNED values +; + extern isr_unsigned_mult24x24 ; isr_xC = isr_xA * isr_xB + ; trashes PRODL, PRODH, WREG + extern isr_unsigned_mult32x24 ; isr_xC = isr_xA * isr_xB + ; trashes PRODL, PRODH, WREG + ;----------------------------------------------------------------------------- ; MULTIPLICATION with SIGNED values ; extern isr_signed_mult16x16 ; isr_xC = isr_xA * isr_xB ; trashes PRODL, PRODH, WREG + + extern isr_signed_mult24x24 -;----------------------------------------------------------------------------- \ No newline at end of file +;----------------------------------------------------------------------------- + +; DIVISION with UNSIGNED values +; + extern isr_div16x16 ; isr_xC:2 = isr_xA:2 / isr_xB:2 with isr_xA as remainder + ; trashes xB, WREG + +;----------------------------------------------------------------------------- +; DIVISION with UNSIGNED values +; + + extern isr_div32x16 ; isr_xC:4 = isr_xC:4 / isr_xB:2 with isr_xA as remainder
--- a/src/menu_processor.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/menu_processor.asm Mon May 24 18:41:51 2021 +0200 @@ -69,12 +69,12 @@ VARARGS_GET8 menu_item_count ; get number of items VARARGS_GET8 menu_vertical_start ; get vertical start position of 1st menu item - movf menu_vertical_start,W ; excite flags, vertical start = 0, i.e. no menu title text? - bz menu_processor_no_title ; YES - skip reading menu title text address - +; movf menu_vertical_start,W ; excite flags, vertical start = 0, i.e. no menu title text? +; bz menu_processor_no_title ; YES - skip reading menu title text address +; VARARGS_GET16 menu_title_addr ; get address of menu title text -menu_processor_no_title: +;menu_processor_no_title: movff TBLPTRL, menu_item_data_start+0 ; store base address of menu items for menu_read_menu_item_data movff TBLPTRH, menu_item_data_start+1 ; ... @@ -91,7 +91,30 @@ ; draw a frame around the dive mode menu movf pallet_color_mask,W ; get mask color into WREG WIN_FRAME_COLOR dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right - bra menu_processor_menu_body ; the dive mode menu has no menu title and footer + + btfss alt_layout_active ; big menu selected? + bra menu_processor_menu_body ; No, the normal dive mode menu has no title and footer + + ; draw menu title + WIN_BOX_BLACK dm_menu_row+.2,dm_menu_row+.26,dm_menu_left+.2,dm_menu_right-.2 ; clear menu title area + WIN_SMALL .2, dm_menu_row+.2 ; set menu title font and position + FONT_COLOR color_greenish ; set menu title font color + movff menu_title_addr+0,FSR1L ; point to multi-lingual menu title text + movff menu_title_addr+1,FSR1H ; ... + call strcpy_text_FSR ; copy translated text into the buffer + movf FSR2L,W ; get title text length + mullw .7 ; compute title length in pixels_x2 + bcf STATUS,C ; divide by 2 + rrcf PRODL ; ... + movf PRODL,W ; get result into WREG + sublw .80 ; compute 80 (screen center position) - half title width in pixel_x2 + movwf win_leftx2 ; set result as horizontal start position + movlw MAX_LINE_LENGTH_TITLE ; load max allowed length of a menu title + movwf FSR2L ; set buffer pointer to end of max length + clrf INDF2 ; terminate string at max length + PRINT ; output menu title + + bra menu_processor_menu_body ; the dive mode menu has no footer menu_processor_menu_title: ; prepare screen @@ -348,7 +371,7 @@ ;bra menu_draw_lines_divemode_big ; YES menu_draw_lines_divemode_big: - WIN_STD dm_menu_item1_column+.16,dm_menu_item1_row+.22 + WIN_STD dm_menu_item1_column+.16,dm_menu_item1_row+.28 decf menu_pos_cur,W ; get selected item as 0..5 into WREG movwf menu_item_start ; set first item to draw = selected item bra menu_draw_menu_items_common ; continue with common part @@ -523,7 +546,7 @@ ;bra menu_draw_cursor_dive_big ; YES menu_draw_cursor_dive_big: - WIN_STD dm_menu_item1_column,dm_menu_item1_row+.20 + WIN_STD dm_menu_item1_column,dm_menu_item1_row+.26 bra menu_draw_cursor_common ; print cursor ENDIF ; _big_divemenu
--- a/src/menu_processor.inc Sat Nov 21 17:46:29 2020 +0100 +++ b/src/menu_processor.inc Mon May 24 18:41:51 2021 +0200 @@ -53,7 +53,7 @@ ; ; nb_items number of menu items that will follow ; -MENU_BEGIN_DIVE MACRO nb_items +MENU_BEGIN_DIVE MACRO title_text_addr, nb_items items_target set nb_items items_count set 0 @@ -67,12 +67,13 @@ ENDIF ; store code for menu execution + extern title_text_addr ; 2 byte address of multi-lingual title text extern menu_processor call menu_processor ; store menu header data db nb_items, 0x00 ; number of items, encoding for no menu titel - + db low(title_text_addr), high(title_text_addr) ; address of multi-lingual title text ENDM
--- a/src/menu_tree.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/menu_tree.asm Mon May 24 18:41:51 2021 +0200 @@ -1338,7 +1338,11 @@ output_hex ; print C5, high byte movff C5+0,WREG ; get C5, low byte output_hex ; print C5, low byte - return ; done + btfss press_sensor_type ; =1: pressure sensor MS5837, =0: Pressure sensor MS5541 + return ; MS5541, done + PUTC "*" + return ; MS5837, done + ;-----------------------------------------------------------------------------
--- a/src/ms5541.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/ms5541.asm Mon May 24 18:41:51 2021 +0200 @@ -11,7 +11,8 @@ #include "hwos.inc" ; Mandatory header #include "math.inc" ; Math routines - +#include "i2c.inc" +#include "shared_definitions.h" ; mailbox from/to p2_deco.c ms5541 CODE @@ -31,6 +32,9 @@ calculate_compensation: banksel isr_backup ; select bank ISR data + btfsc press_sensor_type ; New sensor found? + bra press_comp_ms5837 ; Yes, use MS5837 + ;---- pressure sensor compensation ; xdT = D2 - C5 (s16 range -11.400 .. +12.350) @@ -131,7 +135,7 @@ MOVII SENS,isr_xB ; sens --> B call isr_signed_mult16x16 ; C = A*B - movlw .13 ; 12 * 256 = 3328 + movlw .15 ; 15 * 256 = 3840 cpfslt C1+1 ; C1 > 3328 ? bra isr_shift_ms5541_30 ; YES - MS5541-30 movlw .12-.8 ; NO - MS5541: 12 bit shift = 1 byte + 4 bits @@ -144,7 +148,150 @@ addwf isr_xC+1,F ; ... movlw HIGH .1000 ; ... addwfc isr_xC+2,F ; ... + bra press_comp_done_common +press_comp_ms5837: + ; xdT = D2 - C5*2^8 + movlw .0 ; Low + subwf D2+0,W + movwf xdT+0 + movf C5+0,W ; High + subwfb D2+1,W + movwf xdT+1 + movf C5+1,W ; Upper + subwfb D2+2,W + movwf xdT+2 + ; xdT equals D2 - (C5*2^8) + + ; Calculate OFF = C2*2^16+(C4*xdT)/2^7 + movff C4+0,isr_xA+0 + movff C4+1,isr_xA+1 + clrf isr_xA+2 + movff xdT+0,isr_xB+0 + movff xdT+1,isr_xB+1 + movff xdT+2,isr_xB+2 + call isr_signed_mult24x24 ; C = A*B + ; isr_xC:6 equals (C4*xdT) + rlcf isr_xC+0,F + rlcf isr_xC+1,F + rlcf isr_xC+2,F + rlcf isr_xC+3,F + rlcf isr_xC+4,F + rlcf isr_xC+5,F + movff isr_xC+1,OFF+0 + movff isr_xC+2,OFF+1 + movff isr_xC+3,OFF+2 + movff isr_xC+4,OFF+3 + ; OFF equals (C4*xdT)/2^7 + movf C2+0,W + addwf OFF+2,F + movf C2+1,W + addwfc OFF+3,F + ; OFF equals C2*2^16+((C4*xdT)/2^7) + + ; Calculate SENS = C1*2^15 + (C3*xdT)/2^8 + MOVII C1,isr_xA + movlw LOW (.32768) + movwf isr_xB+0 + movlw HIGH (.32768) + movwf isr_xB+1 + call isr_unsigned_mult16x16 ; C = A*B + movff isr_xC+0,SENS+0 + movff isr_xC+1,SENS+1 + movff isr_xC+2,SENS+2 + movff isr_xC+3,SENS+3 ; 32bit copy + ; SENS equals C1*2^15 + movff C3+0,isr_xA+0 + movff C3+1,isr_xA+1 + clrf isr_xA+2 + movff xdT+0,isr_xB+0 + movff xdT+1,isr_xB+1 + movff xdT+2,isr_xB+2 + call isr_signed_mult24x24 ; C = A*B + ; isr_xC:6 equals (C3*xdT) + movf isr_xC+1,W + addwf SENS+0,F + movf isr_xC+2,W + addwfc SENS+1,F + movf isr_xC+3,W + addwfc SENS+2,F + movf isr_xC+4,W + addwfc SENS+3,F + ; SENS equals C1*2^15 + (C3*xdT)/2^8 + + ; Calculate PRESSURE = ((D1 * SENS) / 2^21) - OFF) / 2^13 + movff SENS+0,isr_xA+0 + movff SENS+1,isr_xA+1 + movff SENS+2,isr_xA+2 + movff SENS+3,isr_xA+3 + movff D1+0,isr_xB+0 + movff D1+1,isr_xB+1 + movff D1+2,isr_xB+2 + call isr_unsigned_mult32x24 ; C = A*B + ; isr_xC:7 equals D1*SENS + + ; devide isr_xC:7 / 2^21 -> shift right 21 times + movlw .21 +press_comp_ms5837_2: + bcf STATUS,C ; clear carry, needed for MS5837 use + rrcf isr_xC+6,F + rrcf isr_xC+5,F + rrcf isr_xC+4,F + rrcf isr_xC+3,F + rrcf isr_xC+2,F + rrcf isr_xC+1,F + rrcf isr_xC+0,F + decfsz WREG ; decrement loop counter, done? + bra press_comp_ms5837_2 ; NO - loop + ; isr_xC:6 equals (D1*SENS)/2^21 + + ; Calculate isr_xC:6-OFF + movf OFF+0,W ; Low + subwf isr_xC+0,F + movf OFF+1,W ; High + subwfb isr_xC+1,F + movf OFF+2,W ; Upper + subwfb isr_xC+2,F + movf OFF+3,W ; Extra + subwfb isr_xC+3,F + movlw .0 ; ultra + subwfb isr_xC+4,F + movlw .0 ; Hyper + subwfb isr_xC+5,F + ; isr_xC:5 is now isr_xC:4-OFF + + ; devide by 2^13 + ; devide isr_xC:6 / 2^13 -> shift right 13 times + movlw .13 +press_comp_ms5837_3: + bcf STATUS,C ; clear carry + rrcf isr_xC+5,F + rrcf isr_xC+4,F + rrcf isr_xC+3,F + rrcf isr_xC+2,F + rrcf isr_xC+1,F + rrcf isr_xC+0,F + decfsz WREG ; decrement loop counter, done? + bra press_comp_ms5837_3 ; NO - loop + ; isr_xC:4 equals pressure in .1 mbar + + movlw .10 + movwf isr_xB+0 + clrf isr_xB+1 + call isr_div32x16 ; isr_xC:4 = isr_xC:4 / isr_xB:2 with isr_xA as remainder + ; isr_xC:2 equals pressure in 1mbar + + ; subtract 20mbar from the final result + movlw .20 + subwf isr_xC+0,F + movlw .0 + subwfb isr_xC+1,F + + ; copy for compatibility of the next routines + movff isr_xC+1,isr_xC+2 + movff isr_xC+0,isr_xC+1 + +press_comp_done_common: ; continue here even with MS5837 ; add opt_pressure_adjust to result (SIGNED!) clrf isr_xC+0 ; prepare high byte for adjustment movff opt_pressure_adjust,WREG ; get low byte for adjustment (signed) @@ -256,9 +403,14 @@ addwf pressure_abs_avg+0,F ; pressure_abs_avg += current pressure, low byte movf isr_xC+2,W ; copy current absolute pressure to WREG, high byte addwfc pressure_abs_avg+1,F ; pressure_abs_avg += current pressure, high byte + movlw .0 + addwfc pressure_abs_avg+2,F ; pressure_abs_avg += current pressure, upper byte ;---- temperature sensor compensation + btfsc press_sensor_type ; New sensor found? + bra temp_comp_ms5837 ; Yes, use MS5837 + ; calculate temp = 200 + dT*(C6+100)/2^11 movlw LOW(.100) ; C6 + 100 --> A addwf C6+0,W ; ... @@ -276,7 +428,71 @@ addwf isr_xC+1,F ; ... movlw HIGH(.200) ; ... addwfc isr_xC+2,F ; ... + bra temp_comp_done_common +temp_comp_ms5837: + ; TEMP = 2000+((xdT * C6) / 2^23) + + ; xdT * C6 -> isr_xC:6 + movff C6+0,isr_xA+0 + movff C6+1,isr_xA+1 + clrf isr_xA+2 + movff xdT+0,isr_xB+0 + movff xdT+1,isr_xB+1 + movff xdT+2,isr_xB+2 + call isr_signed_mult24x24 ; A*B + + ; devide isr_xC:6 / 2^23 -> shift right 23 times + ; a special variant (again): We loose isr_xC+0 and isr_xC+1 anyway + ; and do not care about the inserted carry since we won't use isr_xC+5 + ; and we shift less then 8 bytes + movlw .23-.16 +temp_comp_ms5837_2: + rrcf isr_xC+5,F ; + rrcf isr_xC+4,F ; + rrcf isr_xC+3,F ; + rrcf isr_xC+2,F ; ... + decfsz WREG ; decrement loop counter, done? + bra temp_comp_ms5837_2 ; NO - loop + + ; only use +2 and +3 + movlw LOW(.2000) ; add 2000 + addwf isr_xC+2,F ; ... + movlw HIGH(.2000) ; ... + addwfc isr_xC+3,F ; ... + + ; devide by 10 for .1°C resolution + movlw .10 + movwf isr_xB+0 + clrf isr_xB+1 + movff isr_xC+2,isr_xA+0 + movff isr_xC+3,isr_xA+1 + + btfss isr_xC+3,7 ; check sign bit + bra temp_comp_ms5837_3 ; not negative... + ; negate isr_xA:2 to make it positive + comf isr_xA+1 ; 16 bit sign change + negf isr_xA+0 + btfsc STATUS,C ; - carry to propagate? + incf isr_xA+1,F ; YES - do it + +temp_comp_ms5837_3: + call isr_div16x16 ; isr_xC:2 = isr_xA:2 / isr_xB:2 + + btfss isr_xC+3,7 ; check sign bit again + bra temp_comp_ms5837_4 ; not negative... + ; negate result isr_xC:2 to make it negative again + comf isr_xC+1 ; 16 bit sign change + negf isr_xC+0 + btfsc STATUS,C ;- carry to propagate? + incf isr_xC+1,F ; YES - do it + +temp_comp_ms5837_4: + ; copy for compatibility of the next routines + movff isr_xC+1,isr_xC+2 + movff isr_xC+0,isr_xC+1 + +temp_comp_done_common: ; continue here even with MS5837 ; add opt_temperature_adjust to result (SIGNED!) clrf isr_xC+0 ; prepare high byte for adjustment movff opt_temperature_adjust,WREG ; get low byte for adjustment (signed) @@ -309,12 +525,13 @@ ; global get_pressure_start get_pressure_start: + btfsc press_sensor_type ; New sensor found? + return ; Yes, ignore routine rcall reset_MS5541 ; reset the chip movlw b'10100000' ; +3*high as start and 1+low as stop movwf dbuffer ; .... movlw d'12' ; send start command - rcall send_data_MS5541 ; ... - return ; done + bra send_data_MS5541 ; ... (And return) ;----------------------------------------------------------------------------- @@ -324,6 +541,8 @@ ; global get_pressure_value get_pressure_value: + btfsc press_sensor_type ; New sensor found? + bra get_pressure_value2 btfsc MS5541_miso ; conversion done? return ; NO - abort rcall get_2bytes_MS5541 ; YES - read result @@ -331,6 +550,14 @@ movff dLSB,D1+0 ; ... low byte second return ; done +get_pressure_value2: + btfsc i2c_busy_pressure ; currently updating pressure? + return ; Yes, skip update... + movff D1_buffer+0,D1+0 + movff D1_buffer+1,D1+1 + movff D1_buffer+2,D1+2 + return + ;----------------------------------------------------------------------------- ; Start Temperature Measurement @@ -339,12 +566,13 @@ ; global get_temperature_start get_temperature_start: + btfsc press_sensor_type ; New sensor found? + return ; Yes, ignore routine rcall reset_MS5541 ; reset chip movlw b'10010000' ; +3*high as start and 1+low as stop movwf dbuffer ; ... movlw d'12' ; send start command - rcall send_data_MS5541 ; ... - return ; done + bra send_data_MS5541 ; ... (And return) ;----------------------------------------------------------------------------- @@ -354,6 +582,8 @@ ; global get_temperature_value get_temperature_value: + btfsc press_sensor_type ; New sensor found? + bra get_temperature_value2 btfsc MS5541_miso ; conversion done? return ; NO - done rcall get_2bytes_MS5541 ; YES - read result @@ -361,6 +591,14 @@ movff dLSB,D2+0 ; ... low byte second return ; done +get_temperature_value2: + btfsc i2c_busy_temperature ; currently updating temperature? + return ; Yes, skip update... + movff D2_buffer+0,D2+0 + movff D2_buffer+1,D2+1 + movff D2_buffer+2,D2+2 + return + ;----------------------------------------------------------------------------- ; Retrieve Calibration Data @@ -370,8 +608,15 @@ global get_calibration_data get_calibration_data: banksel isr_backup ; select bank ISR data - bsf block_sensor_interrupt ; disable sensor interrupts + bsf block_sensor_interrupt ; disable sensor interrupts + btfsc press_sensor_type ; New sensor found? + call I2C_get_calib_MS5837 ; Yes, read C1 to C6 + banksel isr_backup ; select bank ISR data + + btfsc press_sensor_type ; New sensor found? + bra get_calibration_data2 ; Yes, skip to the end + rcall reset_MS5541 ; reset chip movlw b'01010100' ; +3*high as start and 1+low as stop @@ -545,6 +790,7 @@ movff ir_s8_buffer+6,C6+0 bcf C6+0,7 +get_calibration_data2: clrf sensor_state_counter ; reset state counter bcf block_sensor_interrupt ; re-enable sensor interrupts banksel common ; back to bank common
--- a/src/option_table.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/option_table.asm Mon May 24 18:41:51 2021 +0200 @@ -147,7 +147,7 @@ OPTION_UINT8 oaGF_low, .10, .100, .30, tPercent, 0x023, 0x27, opt_aGF_low ; alternative GF low OPTION_UINT8 oaGF_high, .45, .110, .85, tPercent, 0x024, 0x28, opt_aGF_high ; alternative GF high OPTION_BOOL oEnable_aGF, .0, 0x025, 0x29, opt_enable_aGF ; =1: aGF can be selected underwater - OPTION_UINT8 oCompassGain, .0, .7, .5, tMinutes, 0x026, 0x34, opt_compass_gain ; 0-7 (230 LSB/Gauss to 1370LSB/Gauss) + OPTION_UINT8 oCompassGain, .0, .5, .5, tMinutes, 0x026, 0x34, opt_compass_gain ; 0-7 (230 LSB/Gauss to 1370LSB/Gauss) OPTION_ENUM8 oSamplingRate, .2, .0, tSetSeconds, 0x027, 0x2F, opt_sampling_rate ; =1: 10s, =0: 2s ; Managing Settings @@ -318,8 +318,8 @@ OPTION_ENUM8 oTissueGraphics, tissue_graphics_options, .0, tTissuePresSat, 0x0FB, 0x88, opt_tissue_graphics ; =0: show pressures and saturations, =1: show N2 and He pressures OPTION_ENUM8 oLayout, .2, .0, tLayoutNormal, 0x0FC, 0x8A, opt_layout ; initial layout of dive mode screen =0: normal, =1: big OPTION_BOOL oExtendedStops, .1, 0x0FD, 0x8B, opt_ext_stops ; =1: place gas switches also below 1st stop depth - OPTION_UINT8 oGasDensityAtt, .40, .80, .60, nounit, 0x0FE, 0x8C, char_I_gas_density_att ; threshold for gas density attention [0.1 grams/l] - OPTION_UINT8 oGasDensityWarn, .40, .80, .65, nounit, 0x0FF, 0x8D, char_I_gas_density_warn ; threshold for gas density warning [0.1 grams/l] + OPTION_UINT8 oGasDensityAtt, .40, .80, .52, nounit, 0x0FE, 0x8C, char_I_gas_density_att ; threshold for gas density attention [0.1 grams/l] + OPTION_UINT8 oGasDensityWarn, .40, .80, .63, nounit, 0x0FF, 0x8D, char_I_gas_density_warn ; threshold for gas density warning [0.1 grams/l] OPTION_BOOL oDilppO2Check, .1, 0x100, 0x8E, char_I_dil_check ; =1: check ppO2 of the pure diluent against current setpoint OPTION_UINT8 oFirmwareMajor, fw_version_major, fw_version_major, fw_version_major, nounit, 0x101, nocomm, opt_fw_version_major ; firmware version, major | use as read-only, OPTION_UINT8 oFirmwareMinor, fw_version_minor, fw_version_minor, fw_version_minor, nounit, 0x102, nocomm, opt_fw_version_minor ; firmware version, minor | do not change eeprom index number!
--- a/src/p2_deco.c Sat Nov 21 17:46:29 2020 +0100 +++ b/src/p2_deco.c Mon May 24 18:41:51 2021 +0200 @@ -128,6 +128,9 @@ #define BAR_TO_METER 10.19716 // conversion factor (1 bar = 10.19716 m ) #define SURFACE_DESAT_FACTOR 0.70420 // surface desaturation safety factor #define HYST 1.0E-06 // threshold for tissue graphics on-gassing / off-gassing visualization +#define GAS_DENSITY_He_FACTOR 17.64 // in multiples of 0.01 grams per liter +#define GAS_DENSITY_N2_FACTOR 123.46 // in multiples of 0.01 grams per liter +#define GAS_DENSITY_O2_FACTOR 141.02 // in multiples of 0.01 grams per liter // thresholds #define CNS_LIMIT_WARNING 100 // threshold for CNS warning @@ -136,11 +139,12 @@ #define PRESSURE_LIMIT_ATTENTION 500 // threshold for pressure reading attention: 50.0 bar #define GAS_NEEDS_ATTENTION 0.7 // threshold for gas needs attention [1 = 100%] #define O2_CONSUMPTION_LIMIT_ATTENTION 20 // threshold for O2 "SAC" attention: 2.0 l/min -#define ppO2_GAP_TO_SETPOINT 10 // gap between setpoint and max. ppO2 of the pure diluent [cbar] +#define ppO2_GAP_TO_SETPOINT 20 // gap between setpoint and max. ppO2 of the pure diluent [cbar] #define ppO2_MARGIN_ON_MAX 3 // [cbar] margin on ppO2 max to compensate for surface pressures > 1.000 mbar #define STOP_CHAINING_LIMIT 3 // max. number of chained stop table entries before deco calculation is aborted + // deco engine states and modes - (char_O_)main_status: controls current tissue and deco status calculation (as-is situation) #define CALC_VOLUME 0x01 // =1: calculate gas needs #define CALCULATE_BOTTOM 0x02 // =1: calculate gas needs in deco calculator mode, =0: in dive mode @@ -1943,7 +1947,7 @@ overlay unsigned char temp; // compute gas density of current mix in multiples of 0.01 grams per liter - int_O_gas_density = (unsigned int)( 17.9 * ppHe + 125.1 * ppN2 + 142.8 * ppO2 ); + int_O_gas_density = (unsigned int)( GAS_DENSITY_He_FACTOR * ppHe + GAS_DENSITY_N2_FACTOR * ppN2 + GAS_DENSITY_O2_FACTOR * ppO2 ); // convert gas density into an 8 bit integer, scaling 0.1 grams per liter temp = (unsigned char)( (int_O_gas_density + 9) / 10 );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rx_firmware-1-41.inc Mon May 24 18:41:51 2021 +0200 @@ -0,0 +1,172 @@ +;============================================================================= +; +; File rx_firmware.inc combined next generation V3.09.4f +; +; Firmware for the RX Co-Processor +; +; Copyright (c) 2019, HeinrichsWeikamp, all rights reserved. +;============================================================================= + + +; version of the RX firmware below +#define rx_firmware_major .1 +#define rx_firmware_minor .41 + +; http://srecord.sourceforge.net/ + DB 0xF7,0xEF,0x05,0xF0,0x00,0x00,0x00,0x00,0x03,0xD0,0x00,0x00 + DB 0x00,0x00,0x00,0x00,0x01,0x01,0xF3,0xCF,0x60,0xF0,0xF4,0xCF + DB 0x61,0xF0,0x7E,0xB0,0x87,0xD8,0xF0,0xB2,0xC8,0xD8,0x7B,0xB0 + DB 0x0E,0xD8,0x01,0x01,0x9E,0xB0,0xBF,0xD8,0x9E,0xB2,0xB0,0xD8 + DB 0xA1,0xB2,0xB7,0xD8,0xF2,0xB2,0xF2,0x92,0x61,0xC0,0xF4,0xFF + DB 0x60,0xC0,0xF3,0xFF,0x11,0x00,0x0F,0x01,0x4F,0x6B,0x50,0x6B + DB 0x01,0x01,0x7B,0x90,0x5E,0xCF,0x3D,0xF1,0x5E,0xCF,0x40,0xF1 + DB 0xD8,0x90,0x40,0x33,0x3F,0x51,0x40,0x27,0x02,0x8D,0xA0,0x0E + DB 0x7D,0xB0,0x06,0x51,0x40,0x61,0x02,0x9D,0xD8,0x90,0x3D,0x31 + DB 0x3F,0x6F,0x02,0xAD,0x82,0x94,0x02,0xBD,0x82,0x84,0x40,0xC1 + DB 0x73,0xFF,0x0F,0x01,0x51,0xB5,0x12,0x00,0x01,0x01,0x02,0xAD + DB 0x06,0xD0,0x41,0x2B,0x40,0x51,0x45,0x27,0x00,0x0E,0x46,0x23 + DB 0x12,0x00,0x42,0x2B,0x2B,0x0E,0x41,0x61,0x12,0xD0,0x0A,0x0E + DB 0x42,0x61,0x03,0xD0,0x05,0x0E,0x41,0x61,0x05,0xD0,0x41,0x6B + DB 0x42,0x6B,0x45,0x6B,0x46,0x6B,0x12,0x00,0x42,0x51,0x41,0x27 + DB 0x2B,0x0E,0x41,0x61,0x02,0xD0,0x42,0x6B,0x12,0x00,0x41,0xC1 + DB 0x06,0xF1,0x70,0x0E,0x4E,0x6F,0x17,0x0E,0x4F,0x6F,0x45,0xC1 + DB 0x4C,0xF1,0x46,0xC1,0x4D,0xF1,0x92,0xEC,0x07,0xF0,0x49,0xB1 + DB 0xE6,0xD7,0x45,0xC1,0x47,0xF1,0x46,0xC1,0x48,0xF1,0x45,0x6B + DB 0x46,0x6B,0x0F,0x01,0x53,0x6B,0xAF,0x0E,0x52,0x6F,0x26,0x0E + DB 0x51,0x6F,0x01,0x01,0x7E,0x90,0x02,0xEE,0x00,0xF0,0x7D,0x80 + DB 0x0C,0x6B,0x0F,0x6B,0x08,0x0E,0x0D,0x6F,0x10,0x0E,0x10,0x6F + DB 0x05,0x0E,0x11,0x6F,0x41,0x6B,0x42,0x6B,0x47,0xC1,0x19,0xF1 + DB 0x48,0xC1,0x1A,0xF1,0x06,0xC1,0x1B,0xF1,0x1C,0x6B,0x6B,0xEC + DB 0x07,0xF0,0x05,0x0E,0x15,0x27,0x15,0xC1,0x06,0xF1,0x12,0x00 + DB 0x0F,0x01,0xFB,0x0E,0x52,0x6F,0x05,0x0E,0x51,0x6F,0x01,0x01 + DB 0x7E,0x90,0x05,0x0E,0x10,0x65,0x06,0xD0,0x0D,0x0E,0x10,0x61 + DB 0x03,0xD0,0x80,0x7C,0x02,0xBD,0x0F,0x2B,0x10,0x2F,0x12,0x00 + DB 0x10,0x0E,0x10,0x6F,0x02,0x0E,0xD8,0x80,0x0F,0x65,0xD8,0x90 + DB 0x0E,0x37,0x0C,0x67,0x07,0xD0,0x0E,0xB1,0x05,0xD0,0x0F,0x01 + DB 0x51,0x95,0x01,0x01,0x7D,0x90,0x12,0x00,0x0F,0x6B,0x0C,0x2B + DB 0x0D,0x2F,0x12,0x00,0x08,0x0E,0x0D,0x6F,0x0E,0xC1,0xEE,0xFF + DB 0x11,0x2F,0x12,0x00,0x0F,0x01,0x51,0x95,0x01,0x01,0x7D,0x90 + DB 0x02,0x85,0x12,0x00,0x9E,0x92,0x01,0x01,0x2B,0x2B,0x3E,0x0E + DB 0x2B,0x65,0x12,0x00,0x2B,0x6B,0x02,0x87,0x12,0x00,0x01,0x01 + DB 0xA0,0x92,0xA1,0x92,0x12,0x00,0x01,0x01,0x9E,0x90,0x9D,0x90 + DB 0x12,0x00,0x01,0x01,0xF0,0x92,0x12,0x00,0x12,0xEE,0x10,0xF0 + DB 0x00,0xC3,0xE6,0xFF,0x10,0xC3,0xE6,0xFF,0x20,0xC3,0xE6,0xFF + DB 0x30,0xC3,0xE6,0xFF,0x40,0xC3,0xE6,0xFF,0x50,0xC3,0xE6,0xFF + DB 0x01,0xC3,0xE6,0xFF,0x11,0xC3,0xE6,0xFF,0x21,0xC3,0xE6,0xFF + DB 0x31,0xC3,0xE6,0xFF,0x41,0xC3,0xE6,0xFF,0x51,0xC3,0xE6,0xFF + DB 0x02,0xC3,0xE6,0xFF,0x12,0xC3,0xE6,0xFF,0x22,0xC3,0xE6,0xFF + DB 0x32,0xC3,0xE6,0xFF,0x42,0xC3,0xE6,0xFF,0x52,0xC3,0xE6,0xFF + DB 0x02,0x99,0x12,0x00,0x03,0x01,0x50,0x67,0x50,0x2B,0x51,0x67 + DB 0x51,0x2B,0x52,0x67,0x52,0x2B,0x53,0x67,0x53,0x2B,0x54,0x67 + DB 0x54,0x2B,0x55,0x67,0x55,0x2B,0x56,0x67,0x56,0x2B,0x13,0xEE + DB 0x00,0xF0,0x00,0x0E,0x0F,0xD8,0x01,0x0E,0x0D,0xD8,0x02,0x0E + DB 0x0B,0xD8,0x03,0x0E,0x09,0xD8,0x04,0x0E,0x07,0xD8,0x05,0x0E + DB 0x05,0xD8,0x06,0x0E,0x03,0xD8,0x01,0x01,0x02,0x89,0x12,0x00 + DB 0x60,0x6F,0x50,0x0F,0xE3,0xCF,0x61,0xF3,0xF0,0x0E,0x61,0x63 + DB 0x12,0x00,0x60,0x51,0xE3,0x6A,0x10,0x0E,0x60,0x25,0xE3,0x6A + DB 0x20,0x0E,0x60,0x25,0xE3,0x6A,0x30,0x0E,0x60,0x25,0xE3,0x6A + DB 0x40,0x0E,0x60,0x25,0xE3,0x6A,0x50,0x0E,0x60,0x25,0xE3,0x6A + DB 0x12,0x00,0x01,0x01,0x00,0xC2,0x2D,0xF1,0x01,0xC2,0x2E,0xF1 + DB 0x02,0xC2,0x2F,0xF1,0x03,0xC2,0x30,0xF1,0x04,0xC2,0x31,0xF1 + DB 0x02,0x95,0x32,0x6B,0x33,0x6B,0x34,0x6B,0x35,0x6B,0x36,0x6B + DB 0x37,0x6B,0x2D,0xBF,0x33,0x8B,0x2D,0xBD,0x33,0x89,0x2D,0xBB + DB 0x33,0x87,0x2D,0xB9,0x33,0x85,0x2D,0xB7,0x33,0x83,0x2D,0xB5 + DB 0x33,0x81,0x2D,0xB3,0x34,0x8F,0x2D,0xB1,0x34,0x8D,0x2E,0xBF + DB 0x34,0x8B,0x2E,0xBD,0x34,0x89,0x2E,0xBB,0x34,0x87,0x2E,0xB9 + DB 0x34,0x85,0x2E,0xB7,0x34,0x83,0x2E,0xB5,0x34,0x81,0x33,0xC1 + DB 0x38,0xF1,0x38,0x9B,0x38,0x67,0x01,0xD0,0x00,0xD0,0x04,0x0E + DB 0x38,0x6F,0x11,0xEE,0x2D,0xF0,0x50,0x6B,0xE6,0x50,0x50,0x1B + DB 0x08,0x0E,0x51,0x6F,0xD8,0x90,0x50,0x37,0x85,0x0E,0xD8,0xB0 + DB 0x50,0x1B,0x51,0x2F,0xF9,0xD7,0x38,0x2F,0xF3,0xD7,0x31,0x51 + DB 0x50,0x63,0x12,0x00,0x2E,0xB3,0x35,0x87,0x2E,0xB1,0x35,0x85 + DB 0x2F,0xBF,0x35,0x83,0x2F,0xBD,0x35,0x81,0x2F,0xBB,0x36,0x8F + DB 0x2F,0xB9,0x36,0x8D,0x2F,0xB7,0x36,0x8B,0x2F,0xB5,0x36,0x89 + DB 0x2F,0xB3,0x36,0x87,0x2F,0xB1,0x36,0x85,0x30,0xBF,0x36,0x83 + DB 0x30,0xBD,0x36,0x81,0x00,0x0E,0x36,0x63,0x05,0xD0,0x0C,0x0E + DB 0x35,0x63,0x02,0xD0,0x36,0x6B,0x35,0x6B,0xE4,0x0E,0x21,0x6F + DB 0x0C,0x0E,0x22,0x6F,0x36,0xC1,0x1F,0xF1,0x35,0xC1,0x20,0xF1 + DB 0x5C,0xEC,0x07,0xF0,0x02,0xB1,0x01,0xD0,0x12,0x00,0x30,0xBB + DB 0x37,0x8B,0x30,0xB9,0x37,0x89,0x30,0xB7,0x37,0x87,0x30,0xB5 + DB 0x37,0x85,0x30,0xB3,0x37,0x83,0x30,0xB1,0x37,0x81,0x38,0x6B + DB 0x13,0xEE,0x00,0xF0,0x23,0xEE,0x10,0xF0,0x33,0x51,0xE6,0x62 + DB 0x1E,0xD0,0x34,0x51,0xDE,0x62,0x1C,0xD0,0x13,0xEE,0x00,0xF0 + DB 0x38,0x51,0x33,0xC1,0xE3,0xFF,0x13,0xEE,0x10,0xF0,0x34,0xC1 + DB 0xE3,0xFF,0x13,0xEE,0x20,0xF0,0x35,0xC1,0xE3,0xFF,0x13,0xEE + DB 0x30,0xF0,0x36,0xC1,0xE3,0xFF,0x13,0xEE,0x40,0xF0,0x37,0xC1 + DB 0xE3,0xFF,0x13,0xEE,0x50,0xF0,0xE3,0x6A,0xE3,0x2A,0x02,0x89 + DB 0x12,0x00,0xDE,0x50,0x38,0x2B,0x04,0x0E,0x38,0x63,0xDA,0xD7 + DB 0x38,0x6B,0x13,0xEE,0x50,0xF0,0xE6,0x66,0x01,0xD0,0xDA,0xD7 + DB 0x38,0x2B,0x04,0x0E,0x38,0x63,0xF9,0xD7,0x12,0x00,0x95,0xD8 + DB 0x5C,0xD8,0x27,0x6B,0x80,0x88,0x80,0xA8,0xFD,0xD7,0x02,0x9B + DB 0x2B,0x6B,0x12,0xEE,0x00,0xF0,0xE6,0x6A,0x0F,0x0E,0xE2,0x62 + DB 0xFC,0xD7,0x01,0x01,0x9E,0xB6,0xF1,0xD8,0x02,0xBB,0xED,0xD7 + DB 0x02,0xB9,0xD0,0xDE,0x02,0xB5,0x31,0xDF,0x02,0xB7,0x02,0xD8 + DB 0x04,0x00,0xF4,0xD7,0x02,0x97,0x29,0x4B,0x2A,0x2B,0xEE,0xDE + DB 0x81,0xB0,0x06,0xD8,0x81,0xA0,0x3B,0x6B,0x28,0x2F,0x12,0x00 + DB 0x06,0xD8,0x12,0x00,0x01,0x01,0x3B,0x2B,0x1E,0x0E,0x3B,0x63 + DB 0x12,0x00,0x3B,0x6B,0xF2,0x6A,0xF0,0x6A,0x9D,0x6A,0x80,0x0E + DB 0xF1,0x6E,0xCD,0x6A,0xB1,0x6A,0x0F,0x01,0x42,0x6B,0x41,0x6B + DB 0x01,0x01,0x00,0x00,0x00,0x00,0x80,0x98,0x80,0xB8,0xFD,0xD7 + DB 0x2A,0x6B,0x29,0x6B,0x9E,0x96,0x03,0x00,0x00,0x00,0x81,0xB0 + DB 0xFB,0xD7,0x00,0x00,0x80,0x88,0x80,0xA8,0xFD,0xD7,0xCD,0x6A + DB 0x82,0x0E,0xB1,0x6E,0x13,0xEE,0x00,0xF0,0xE6,0x6A,0x04,0x0E + DB 0xE2,0x62,0xFC,0xD7,0x0F,0x01,0x42,0x6B,0xE0,0x0E,0x41,0x6F + DB 0x01,0x01,0xC0,0x0E,0xF2,0x6E,0xF1,0x6A,0x10,0x0E,0xF0,0x6E + DB 0x02,0x0E,0x9D,0x6E,0x12,0x00,0xF2,0x9E,0x23,0x97,0x06,0x69 + DB 0x04,0x6B,0x06,0x2F,0x02,0xD0,0x9B,0x6A,0x1C,0xD0,0xB2,0x6A + DB 0xB1,0x80,0x03,0x6B,0xA1,0x92,0xB3,0x68,0xFC,0x0E,0xB2,0x6E + DB 0x03,0x2B,0xA1,0xA2,0xFD,0xD7,0x03,0x51,0x7A,0x08,0xD8,0xA0 + DB 0x01,0xD0,0x07,0xD0,0xFF,0x08,0x01,0x08,0xD8,0xB0,0x09,0xD0 + DB 0x04,0x07,0x0D,0xD8,0xE6,0xD7,0x01,0x08,0xD8,0xB0,0x03,0xD0 + DB 0x04,0x2B,0x07,0xD8,0xE0,0xD7,0x04,0xC1,0x3C,0xF1,0x82,0x0E + DB 0xB1,0x6E,0xF2,0x8E,0x12,0x00,0x04,0xC1,0x05,0xF1,0x05,0x9F + DB 0x05,0x9D,0x05,0xC1,0x9B,0xFF,0x14,0x0E,0x05,0x6F,0x04,0x00 + DB 0xFF,0xEC,0x02,0xF0,0x05,0x2F,0xFB,0xD7,0x12,0x00,0x0F,0x01 + DB 0x72,0x0E,0xD3,0x6E,0xD2,0x6A,0x9B,0x6A,0xD1,0x80,0x0C,0x0E + DB 0x92,0x6E,0x05,0x0E,0x93,0x6E,0x59,0x0E,0x94,0x6E,0x0F,0x01 + DB 0x04,0x0E,0x38,0x6F,0x39,0x6B,0x3A,0x6B,0x0F,0x01,0x3F,0x6B + DB 0x9B,0x0E,0x3E,0x6F,0x0E,0x0E,0x3D,0x6F,0x0F,0x01,0x04,0x0E + DB 0x61,0x6E,0x0F,0x01,0x80,0x6A,0x81,0x6A,0x82,0x6A,0xD5,0x6A + DB 0xCD,0x6A,0xCC,0x6A,0x7F,0x0E,0xBA,0x6E,0x82,0x0E,0xB1,0x6E + DB 0xB4,0x6A,0x0F,0x01,0x51,0x6B,0x0F,0x01,0x01,0x0E,0x4E,0x6F + DB 0x4D,0x6B,0x0F,0x01,0x04,0x0E,0x4A,0x6F,0x0F,0x01,0x42,0x6B + DB 0xE0,0x0E,0x41,0x6F,0x16,0x0E,0x40,0x6F,0x01,0x01,0xC2,0x6A + DB 0xAC,0x6A,0xAB,0x6A,0xB8,0x6A,0xAF,0x6A,0xB0,0x6A,0x24,0x0E + DB 0x72,0x6E,0x80,0x0E,0x71,0x6E,0x08,0x0E,0x70,0x6E,0x22,0x0E + DB 0x75,0x6E,0x76,0x6A,0x50,0x0E,0xC8,0x6E,0xC7,0x6A,0x26,0x0E + DB 0xC6,0x6E,0x08,0x0E,0xC5,0x6E,0xCB,0x6A,0xCA,0x68,0xC6,0x88 + DB 0x23,0x6B,0x26,0x6B,0x9E,0x96,0x0F,0x01,0x92,0x0E,0x49,0x6F + DB 0x0F,0x01,0x07,0x0E,0x5D,0x6F,0x0F,0x01,0x01,0x0E,0x5A,0x6F + DB 0x0F,0x01,0x5C,0x6B,0x0F,0x01,0x5B,0x6B,0x0F,0x01,0xC0,0x0E + DB 0xF2,0x6E,0xF1,0x6A,0xF0,0x6A,0x02,0x0E,0x9D,0x6E,0xA0,0x6A + DB 0xA3,0x6A,0x01,0x0E,0x7A,0x6E,0x01,0x01,0x12,0x00,0x9E,0x96 + DB 0x0F,0x0E,0x28,0x6F,0xC9,0xCF,0x24,0xF1,0xC7,0xB4,0x16,0xD0 + DB 0xC7,0xAA,0x11,0xD0,0x23,0x6B,0x1B,0x0E,0x24,0x63,0x02,0xD0 + DB 0x23,0x81,0x0B,0xD0,0x1E,0x0E,0x24,0x63,0x02,0xD0,0x23,0x83 + DB 0x06,0xD0,0x2E,0x0E,0x24,0x63,0x02,0xD0,0x23,0x85,0x01,0xD0 + DB 0x00,0xD0,0x9E,0x96,0xC6,0x88,0x12,0x00,0x23,0xB1,0x1C,0xD0 + DB 0x23,0xB3,0x08,0xD0,0x23,0xB5,0x14,0xD0,0xFF,0x0E,0x24,0xD8 + DB 0x00,0xD0,0x9E,0x96,0xC6,0x88,0x12,0x00,0x23,0x93,0x12,0xEE + DB 0x10,0xF0,0x30,0x0E,0x03,0x6F,0xE6,0x50,0x19,0xD8,0x02,0xBB + DB 0x15,0xD0,0xC5,0xBC,0xF2,0xD7,0x03,0x2F,0xF8,0xD7,0xEF,0xD7 + DB 0x23,0x95,0x12,0xEE,0x40,0xF0,0xF1,0xD7,0x23,0x91,0x01,0x0E + DB 0x0B,0xD8,0x02,0xBB,0x07,0xD0,0xC5,0xBC,0xE4,0xD7,0x29,0x0E + DB 0x05,0xD8,0x02,0xBB,0x01,0xD0,0xDF,0xD7,0x23,0x6B,0xDD,0xD7 + DB 0xC9,0x6E,0xC6,0x88,0x04,0xD0,0xC6,0x88,0x02,0xD8,0xC9,0x50 + DB 0x12,0x00,0x27,0x6B,0x9E,0xB6,0x0B,0xD0,0x9E,0xB6,0x09,0xD0 + DB 0x9E,0xB6,0x07,0xD0,0x9E,0xB6,0x05,0xD0,0x27,0x2F,0x01,0xD0 + DB 0x04,0xD0,0x9E,0xA6,0xFE,0xD7,0x9E,0x96,0x12,0x00,0x02,0x8B + DB 0x9E,0x96,0x12,0x00,0x02,0x91,0x21,0x51,0x1F,0x5D,0x1D,0x6F + DB 0x22,0x51,0x20,0x59,0x1E,0x6F,0xD8,0xB0,0x12,0x00,0x02,0x81 + DB 0x1E,0x1F,0x1D,0x6D,0xD8,0xB0,0x1E,0x2B,0x12,0x00,0x15,0x6B + DB 0x16,0x6B,0x1B,0x51,0x1C,0x11,0xD8,0xB4,0xFF,0x0C,0x01,0x0E + DB 0x14,0x6F,0x1C,0xBF,0x05,0xD0,0x14,0x2B,0xD8,0x90,0x1B,0x37 + DB 0x1C,0x37,0xF9,0xD7,0xD8,0x90,0x15,0x37,0x16,0x37,0x1B,0x51 + DB 0x19,0x5F,0x1C,0x51,0xD8,0xA0,0x1C,0x29,0x1A,0x5F,0xD8,0xB0 + DB 0x05,0xD0,0x1B,0x51,0x19,0x27,0x1C,0x51,0x1A,0x23,0x01,0xD0 + DB 0x15,0x81,0x14,0x07,0xD8,0xB4,0x12,0x00,0xD8,0x90,0x1C,0x33 + DB 0x1B,0x33,0xE8,0xD7,0x49,0x91,0x4E,0x51,0x4C,0x5D,0x4A,0x6F + DB 0x4F,0x51,0x4D,0x59,0x4B,0x6F,0xD8,0xB0,0x12,0x00,0x49,0x81 + DB 0x4B,0x1F,0x4A,0x6D,0xD8,0xB0,0x4B,0x2B,0x12,0x00,0xFF,0xFF + +
--- a/src/rx_firmware.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/rx_firmware.asm Mon May 24 18:41:51 2021 +0200 @@ -21,7 +21,7 @@ global rx_firmware_storage rx_firmware_storage: -#include "rx_firmware-1-40.inc" +#include "rx_firmware-1-41.inc" global rx_firmware_new_major rx_firmware_new_major:
--- a/src/sleepmode.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/sleepmode.asm Mon May 24 18:41:51 2021 +0200 @@ -79,6 +79,8 @@ bsf sleepmode ; flag being in sleep mode bsf block_sensor_interrupt ; suspend ISR from executing sensor interrupts + bcf i2c_error_flag ; clear any I2C errors + call disable_ir_s8_analog ; power-down IR/S8/analog interface call mcp_sleep ; power-down RX power supply @@ -233,6 +235,16 @@ btfsc trigger_full_hour ; one hour in sleep? rcall one_hour_sleep ; YES - do the every hour tasks + ; sleepmode pressure sampling for new sensor is done here + btfss press_sensor_type ; New sensor found? + return ; No, done. + + btfsc ms5837_state ; =0: result of temperature is in the ADC + bra one_sec_sleep_3 + call I2C_get_temp_val_MS5837 ; (Will set ms5837_state) + return +one_sec_sleep_3: + call I2C_get_press_val_MS5837 ; (Will clear ms5837_state) return ; done @@ -394,7 +406,10 @@ pressuretest_sleep_fast: banksel isr_backup ; select bank ISR data - CLRI pressure_abs_avg ; clear pressure average register + clrf pressure_abs_avg+0 ; clear pressure average register + clrf pressure_abs_avg+1 + clrf pressure_abs_avg+2 + CLRI temperature_avg ; clear temperature average register call get_temperature_start ; start temperature integration (73.5 us) @@ -402,13 +417,15 @@ rcall sleepmode_sleep ; sleep for 62.5...125 ms rcall sleepmode_sleep ; sleep for 62.5...125 ms - call get_temperature_value ; state 1: get temperature + call get_temperature_value ; get temperature... (May return in bank common) + banksel isr_backup ; select bank ISR data call get_pressure_start ; start pressure integration rcall sleepmode_sleep ; sleep for 62.5...125 ms rcall sleepmode_sleep ; sleep for 62.5...125 ms - call get_pressure_value ; state2: get pressure (51 us) + call get_pressure_value ; state2: get pressure (51 us)(May return in bank common) + banksel isr_backup ; select bank ISR data call calculate_compensation ; calculate temperature compensated pressure (27 us) MOVII pressure_abs_avg,pressure_abs ; get result, bypassing the averaging
--- a/src/start.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/start.asm Mon May 24 18:41:51 2021 +0200 @@ -114,6 +114,10 @@ movlw .16 ; set averaging span movff WREG,analog_counter ; write to counter (in bank isr_backup) + ; initialize 1/4 second counting register + movlw .4 ; 62,5ms * 4 = 1/4 second + movff WREG,isr_tmr7_helper + ; initialize hardware (ports, timers) and start interrupts call init_ostc ; also selects bank common and sets CPU to normal speed @@ -154,13 +158,25 @@ EEPROM_CC_READ eeprom_button_polarity,button_polarity ; initialize pressure sensor calibration + call I2C_probe_pressure_sensor ; Probe the type of sensor, set/clear press_sensor_type call get_calibration_data ; get calibration data from pressure sensor call TFT_DisplayOff ; turn off display bsf LEDr ; turn on red LED ; wait for valid temperature and pressure - WAITS .3 ; wait 3 seconds + btfsc press_sensor_type ; New sensor found? + call I2C_get_temp_val_MS5837 ; (Will set ms5837_state) + WAITMS .250 + btfsc press_sensor_type ; New sensor found? + call I2C_get_press_val_MS5837 ; (Will clear ms5837_state) + WAITMS .250 + btfsc press_sensor_type ; New sensor found? + call I2C_get_temp_val_MS5837 ; (Will set ms5837_state) + WAITMS .250 + btfsc press_sensor_type ; New sensor found? + call I2C_get_press_val_MS5837 ; (Will clear ms5837_state) + WAITMS .250 ; sensor calibration completed, first valid pressure value is available bcf LEDr ; turn off red LED @@ -325,6 +341,7 @@ clrf HW_descriptor ; hardware - OSTC model descriptor clrf HW_flags_state1 ; hardware - states ; ; DO NOT clear HW_flags_state2 ! + ; ; DO NOT clear HW_flags_state3 ! clrf DM_flags_sensor ; hardware - O2 sensors clrf OS_flags_ISR1 ; operating system - ISR control 1 clrf OS_flags_ISR2 ; operating system - ISR control 2 @@ -384,6 +401,9 @@ ; Do the check for BLE-cR IFDEF _external_sensor bsf mcp_power ; power-up instrumentation amp (used by S8 and analog input) + btfss mcp_power ; power-up completed? + bra $-4 ; NO - loop + WAITMS .1 banksel BAUDCON2 ; select bank for IO register access movlw b'00000000' ; speed generator configuration: BRG16=0, normal for S8 movwf BAUDCON2 ; ... @@ -394,13 +414,21 @@ movlw b'10010000' ; RX configuration movwf RCSTA2 ; ... banksel common ; back to bank common - call get_analog_inputs - movff sensor1_mv+1,lo - movlw .58 ; ~ >1,500V - cpfslt lo ; >58 on the high byte -> confident that there is cR circuity + WAITMS .1 + ; Check sensor 1 input with no limits + movlw b'00000000' ; AVDD Vref+ + movwf ADCON1 ; ... + ; set to read Sensor 1 + extern wait_adc + movlw b'00100001' ; power on ADC, select AN8 + call wait_adc ; wait for ADC + movlw .10 ; ~ >1,900V + cpfslt ADRESH ; >10 on the high byte -> confident that there is cR circuity bsf ext_input_s8_ana ; YES - it's a cR, S8/analog sensor input available call disable_ir_s8_analog ; power-down circuity again ENDIF + + bsf lv_core ; default to low voltage core movlw 0x80 ; point to 0x1F780 movwf TBLPTRL ; ... @@ -502,9 +530,9 @@ restart5: ; configure button_hold_down_allowed flag btfsc lv_core - bsf button_hold_down_allowed,A ; OSTC sport mod. 2019 + bsf button_hold_down_allowed ; OSTC sport mod. 2019 btfsc ext_input_optical - bsf button_hold_down_allowed,A ; OSTC3/old sport + bsf button_hold_down_allowed ; OSTC3/old sport ; manage hardware btfss ext_input_s8_ana ; OSTC with S8/analog input?
--- a/src/surfmode.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/surfmode.asm Mon May 24 18:41:51 2021 +0200 @@ -322,6 +322,10 @@ ; warnings for all modes call check_battery ; check if the battery level should be displayed/warned + IFDEF _debug_output + call check_i2c_error ; check for an I2C error (For debugging purposes only) + ENDIF + btfsc FLAG_apnoe_mode ; done for Apnoe or Gauge mode bra surfmode_check_warnings2 btfsc FLAG_gauge_mode ; done for Apnoe or Gauge mode @@ -426,6 +430,15 @@ call TFT_surfmode_batt ; - update displayed battery voltage btfss timebase_1sec,0 ; - on even second? call surfmode_check_warnings ; YES - check for warnings and display/update them + + btfsc trigger_temp_changed ; - temperature changed? + call TFT_surfmode_temp ; YES - display temperature + bcf trigger_temp_changed ; - clear flag (anyhow) + + btfsc trigger_pres_cur_changed ; YES - pressure changed? + call TFT_surfmode_pres_fast ; YES - display surface pressure, but only if change > threshold + bcf trigger_pres_cur_changed ; - clear flag (anyhow) + IFDEF _rx_functions btfss tr_functions_activated ; - TR functions activated? @@ -442,11 +455,12 @@ housekeeping_0: bsf restart_fast ; default to doing a fast restart (no logos) + btfsc divemode ; NO - need to enter dive mode? + bra housekeeping_0b ; YES - but check again, to filter potential glitches (New sensor) +housekeeping_0a: call check_dive_modes_surf ; check if dive mode needs to be entered, will set dive mode flag if yes btfsc simulatormode ; in simulator mode? bra housekeeping_1 ; YES - can't restart or go to sleep without prior cleanup - btfsc divemode ; NO - need to enter dive mode? - goto restart ; YES - restart, will proceed to dive mode btfss trigger_timeout ; NO - timeout? bra housekeeping_1 ; NO btfsc surfmode_menu ; YES - in surface menus? @@ -454,22 +468,36 @@ bcf restart_fast ; NO - set next restart to be done slow, i.e. with logos goto sleeploop ; - goto sleep mode +housekeeping_0b: + call check_dive_modes_surf ; check if dive mode needs to be entered, will set dive mode flag if yes + btfsc divemode ; NO - really need to enter dive mode? + goto restart ; YES + bra housekeeping_0a ; No, continue above + housekeeping_1: btfss trigger_quarter_second ; new 1/4 second begun? bra housekeeping_2 ; NO ;---- tasks any new 1/4 second ----- - bcf trigger_quarter_second ; YES - clear flag + + btfss press_sensor_type ; New sensor found? + bra housekeeping_1aa ; No + + btfsc ms5837_state ; =0: result of temperature is in the ADC + bra housekeeping_1ab + call I2C_get_temp_val_MS5837 ; (Will set ms5837_state) + bra housekeeping_1aa ; Done. +housekeeping_1ab: + call I2C_get_press_val_MS5837 ; (Will clear ms5837_state) +housekeeping_1aa: IFDEF _external_sensor btfsc imprint_sensor_mv ; - shall imprint sensor mV data? call TFT_imprint_menu_mV ; YES - imprint sensor mV data ENDIF ; _external_sensor btfss imprint_surfmode_data ; - shall imprint all surface mode data? bra housekeeping_2 ; NO - btfsc trigger_pres_cur_changed ; YES - pressure changed? - call TFT_surfmode_pres_fast ; YES - display surface pressure, but only if change > threshold - bcf trigger_pres_cur_changed ; - clear flag (anyhow) + IFDEF _compass movf active_customview,W ; - get current custom view xorlw .6 ; - coding of compass custom view @@ -522,10 +550,6 @@ bra housekeeping_3 ; NO call TFT_surfmode_date ; YES - update displayed date - btfsc trigger_temp_changed ; - temperature changed? - call TFT_surfmode_temp ; YES - display temperature - bcf trigger_temp_changed ; - clear flag (anyhow) - movf active_customview,W ; - get current custom view xorlw .5 ; - coding of tissue custom view btfsc STATUS,Z ; - equal?
--- a/src/tft_outputs.asm Sat Nov 21 17:46:29 2020 +0100 +++ b/src/tft_outputs.asm Mon May 24 18:41:51 2021 +0200 @@ -1571,6 +1571,10 @@ ; depth in meters and decimeters btfsc cur_depth_greater_100m ; was the depth >= 100 meter during last call? rcall TFT_depth_box_black ; YES - clear depth area + + btfsc cur_depth_greater_100m ; was the depth >= 100 meter during last call? + rcall TFT_depth_position_m_ft ; re-set output position for full meters/feet + bcf cur_depth_greater_100m ; current depth is now < 100 meter PRINT ; dump full meters to screen @@ -1596,6 +1600,10 @@ ; full meters only btfss cur_depth_greater_100m ; was the depth >= 100 meter during last call? rcall TFT_depth_box_black ; NO - clear depth area + + btfss cur_depth_greater_100m ; was the depth >= 100 meter during last call? + rcall TFT_depth_position_m_ft ; re-set output position for full meters/feet + bsf cur_depth_greater_100m ; depth is >= 100 meter now REINIT_BUFFER ; re-initialize the output buffer bsf omit_digit_2 ; print depth in full meters, i.e. do not print 1st and 2nd digit @@ -2833,6 +2841,21 @@ WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right return ; done +;----------------------------------------------------------------------------- +; Surface Mode - Message - when "I2CFail" was triggered +; + global TFT_message_i2c_error +TFT_message_i2c_error: + rcall TFT_message_open ; set row and column for the message + tstfsz WREG ; is there room for the message? + return ; NO - skip message in this cycle + STRCPY "I2C " ; print "I2C Error:" + movff i2c_error_vault+0,WREG ; last device adress + output_hex + PUTC " " + movff i2c_error_vault+1,WREG ; last data byte + output_hex + bra TFT_message_close ; finalize message output ;----------------------------------------------------------------------------- ; Surface Mode - Message - Desaturation @@ -6030,7 +6053,6 @@ tft_out16 CODE ;============================================================================= - global TFT_debug_output TFT_debug_output: @@ -6048,14 +6070,33 @@ ; WIN_TINY .0, . 0 ; dive mode: overwrites depth label FONT_COLOR_MEMO ; set color + movff D1+2,lo + output_256 + PUTC "," + movff D1+0,lo + movff D1+1,hi + output_65535 + PRINT + WIN_TINY .100,.45 ; surface mode: fits under the textual logo in the upper right corner + movff D2+2,lo + output_256 + PUTC "," + movff D2+0,lo + movff D2+1,hi + output_65535 + PRINT + WIN_TINY .100,.60 ; surface mode: fits under the textual logo in the upper right corner +; movf HW_flags_state3,W +; output_hex +; PUTC "," movff max_CCPR1L,lo output_256 PUTC "," - movff analog_sw2,lo; left - output_256 - PUTC "," - movff analog_sw1,lo; right - output_256 + movff divesecs_avg_trip+0,lo + movff divesecs_avg_trip+1,hi + output_65535 + + ; ; deco engine scheduling performance ; MOVII int_O_profiling_overrun,mpr ; runtime +/- versus target