Crystal oscillator
Quartz Oscillator 3225 20M OSC
>;Oscillator 1MHzR/C
; command clock 250kHz

Include

Page1macro
bsfSTATUS, RP0; page1
Endm

Page0macro
bcfSTATUS, RP0; page0
Endm

cbLOCk0ch
Time1,temp
Lo_val, hi_val, msn, lsn
Digit1, digit2
Count,read
Ssave, wsave
Flags
Endc

;===========================================
Org00
Gotoinit
Org04
btfssINTCON, T0IF
Gotoend_int

MOVwfwsave
swapfSTATUS,w
MOVwfssave; interrupt protection

Decfcount,f
Decfszread,f
Gotoint2
Calladconv;A/D
MOVlw.16;
MOVwfread

int2MOVfcount,0
btfscSTATUS,Z
Bsfflags,0;eot
bcfINTCON, T0IF

End_intswapfssave,w
MOVwfSTATUS;
Swapfwsave,f;
Swapfwsave,w
Retfie;

;==========Check the table ===============
tableaddwfPCL;portb
Retlwb'01110111';0
Retlwb'00010100';1
Retlwb'00111011';2
Retlwb'00111110';3
Retlwb'01011100';4
Retlwb'01101110';5
Retlwb'01101111';6
Retlwb'00110100';7
Retlwb'01111111';8
Retlwb'01111100';9
Retlw0
Retlw0
Retlw0
Retlw0
Retlw0
Retlw0
Retlw0

;*********************Temperature change******************
lookupaddwfPCL
Retlw.99;00
Retlw.99;01
Retlw.99;02
Retlw.99;03
Retlw.91;04
Retlw.81;05
Retlw.73;06
Retlw.66;07
Retlw.59;08
Retlw.52;09
Retlw.45;0A
Retlw.39;0B
Retlw.31;0C
Retlw.23;0D
Retlw.13;0E
Retlw.0;0F
Retlw.0;catchfor>f0h

;=========================================================
interpMOVflsn, 0; initial value
Swapflsn,w;swap&save
MOVwfmsn; intow
MOVlw0fh
Andwflsn,f;stripoffupperrubbish
Andwfmsn,f;stripoffupperrubbish
MOVfmsn,0;reload
Calllookup;getvalue
MOVwflo_val;saveit
Incfmsn,w;incrementpointer
Calllookup;getnextvalue
Subwflo_val,w;getdifference&save
MOVwfhi_val

Multaddwfhi_val,f;addtocurrent
Decfszlsn,f;countdownonmultiplyloop
Gotomult
Swapfhi_val,w;divideby16
Andlw0fh;extractuppernibble
Subwflo_val,w;addlovaluetolovaluetogetresult
Return

adconvbsfADCON0,GO;startconversion
MOVlw.5;waitdelay10uS
MOVwftemp
Decfsztemp,f;loopforawhile
Goto$-1
btfscADCON0,GO;testforendofconversion
Goto$-1
Retlw0

bin_bcdMOVwfdigit1;firstdigit
Clrfdigit2; seconddigit

tenlopMOVlw.10
Subwfdigit1,w;findouthowmany10's
btfscSTATUS, C
Incfdigit2,f
btfscSTATUS, C
MOVwfdigit1;remainder1'sleft
btfscSTATUS, C
Gototenlop
Return

;================================================
initclrfPORTB
clrfPORTA
clrfADCON0
Clrfflags
Page1
MOVlwb'11110011'
MOVwfTRISA
MOVlwb'10000000';
MOVwfTRISB;setupportb
MOVlwb'00000100';/32
MOVwfOPTION_REG
MOVlwb'00000010'
MOVwfADCON1
Page0
MOVlwb'00001000';setupchangeofstateonportb
MOVwfINTCON;towakeup
Sleep;shutdown

MOVlwb'11000001';seta/dinternalrcclock
;channel0,a/drunning
MOVwfADCON0;doit
MOVlw.153; timeoutvalue
MOVwfcount
MOVlw.16;intervaltimerreload
MOVwfread
MOVlwb'10100000';setupchangeofstateonportb
MOVwfINTCON;towakeup
Calladconv;performA/Dconversion

;============================================================================
Mainbtfscflags,0;testfortimeout
Gotoinit;yessoshutdown
MOVfADRES, 0; loadvalue

MOVwflsn;storeforconversion
Callinterp;usinginterpolationmethod

Callbin_bcd;convertinto2digits

MOVfdigit1,0;loadmsb
Calltable;convertinto7segmentformat
MOVwfPORTB; sendtodisplay
bsfPORTA, 2; enablecharacter
btfssTMR0,6; testbit
Goto$-1;loop
bcfPORTA, 2

MOVfdigit2,0;loadlsb
Calltable;convertinto7segmentformat
MOVwfPORTB; sendtodisplay
bsfPORTA,3;enablecharacter
btfscTMR0,6; testbit
Goto$-1;loop
bcfPORTA, 3

Gotomain

End

10KWH All In One Battery

all in one energy;all in one battery,home battery,home energy storage,household power storage,home solar power,all in one system

Shenzhen Enershare Technology Co.,Ltd , https://www.enersharepower.com