,

X

1 2

.

WREG

24 + 1

16 + 16

24 + 16

24 + 24

32 + 16

32 + 32 ( )

E

16 - 8

16 - 16

32 – 32

16 + 16 EEPROM ( )

4

— — 1

USART

USART . .

USART, ,

USART,

MPM

EEPROM

C

/ , ,

RAM

EEPROMa EEPROM



.

PicASM PIC18F.

, .

, PicASM , - , . )

lfsr 0, nameCallRam - RAM

INDF0 - FSR0. FSR0

POSTINC0 - FSR0. FSR0 + 1 .

PREINC0 - FSR0. FSR0 + 1

POSTDEC0 — FSR0. FSR0 - 1 .

PLUSW0 — WREG FSR0. FSR0 WREG .

,

CREATE_ARRAY:


lfsr 0, 0x100 ; 100 fsr0

loop:


movlw 0x55

movwf POSTINC0,0 ; 0x55 FSR0

;clrf POSTINC0, A ; POSTINC0 FSR0

movlw 0x08

cpfseq FSR0L, A ; FSR0L FSR0 0x08

bra loop


COPY_ARRAY:


lfsr 0, 0x100 ; 100 fsr0

lfsr 1, 0x150 ; 100 fsr0

loop2:

movf POSTINC0,W,0 ; FSR0 0x100 ..

movwf POSTINC1,0 ; .. FSR1 ( 0x150)

; FSR1 1


movlw 0x08

cpfseq FSR0L, A ; FSR0L FSR0 0x08

bra loop2


END


TABLAT - 1 , TBLPTRU:H:L

tblrd *+ - TABLAT,

tblrd +* - TABLAT,

tblrd * - TABLAT,

tblrd *- - TABLAT,

; tempG0,

arg set nameTable

movlw upper arg

movwf TBLPTRU,A

errorlevel -311

movlw high arg

errorlevel +311

movwf TBLPTRH,A

movlw low arg

movwf TBLPTRL,A


tblrd *+

movff TABLAT,tempG0


;

tblrd *

movff TABLAT,tG0

TOSU:H:L — SRKPTR

PCU,PCH,PCL – ( )

PCLATU,PCLATH — PCU,PCH. .

PCL – PCLATU,PCLATH

PCL PCU,PCH PCLATU,PCLATH —

fsr2

;

T0CON_WORK equ (1 << TMR0ON) + (0 << T08BIT) + (0 << T0CS) + (0 << T0SE) + (1 << PSA) + (0 << T0PS2) + (0 << T0PS1) +(0 << T0PS0)

;T0CON,TMR0ON,A=1 ;

;T0CON,T08BIT,A=0 ;. 16

;T0CON,T0CS,A=0 ;

;T0CON,T0SE,A=1 ; - TOCKI

;T0CON,PSA,A=0 ; c

;0 << T0PS2) + (0 << T0PS1) +(0 << T0PS0) ;


;

INTCON_WORK equ (0 << GIE) + (0 << PEIE) + (0 << TMR0IE) + (0 << INT0IE) + (0 << RBIE) + (0 << TMR0IF) + (0 << INT0IF) + (0 << RBIF)

;INTCON, GIE, A=1 ;

;INTCON,PEIE,A=1 ;

;INTCON,TMR0IE,A=1 ; TMR0

;INTCON,INT0IE,A=1 ; INT0

;INTCON,RBIE,A=1 ; PORTB

;INTCON,TMR0IF,A=0 ; -

;INTCON,INT0IE,A=1 ; INT0 –

;INTCON,RBIF,A=1 ; PORTB

X

i =0

madr = 1952

while (madr <= 1952+988);1064)


DW_MPM pulse#v(i)D_MADR, madr, 01, 0x00

madr += 76

i += 1

endw

btfss TEMPAL,2,0

OTKL_IDLE_YELLOW

btfsc TEMPAL,2,0

call Routine_VKL_IDLE_YELLOW

btfss TEMPAL,2,0

bra $+8

call Routine_VKL_IDLE_YELLOW

bra $+4

OTKL_IDLE_YELLOW

1 2

WR_RAM_DW:

rcall Get_CRC8_rgsdv_0_4

banksel rgsdv

cpfseq rgsdv+5,B

bra I2C_otvet

- fsr0l fsr0h

rcall Adr_RAM

bcf INTCON,GIE,0

movff rgsdv+3,POSTINC0 -

movff rgsdv+4,INDF0 -

bsf INTCON,GIE,0

bra I2C_otvet

movff TOSL,tempG0

movff TOSH,tempG1

movff TOSU,tempG2


movlw 0x4C

cpfseq EEADR, A

bra $+10

movlw 0x08

cpfseq EEMADRH, A

bra $+4

nop


bsf TEMPAL,0,0 -

6720

20

nop 0,2


5000 nop 1

5 nop – 1uS

2- RAM . / .

;!!!test

TestTwoByteEqu:

arg set 475

movlw high arg

movff WREG,tmp1

movlw low arg

movff WREG,tmp0

banksel tmp0

movff ram_param_idx_h,WREG

cpfseq tmp1,1

bra TwoByteNoEqu

movff ram_param_idx_l,WREG

cpfseq tmp0,1

bra TwoByteNoEqu

bra TwoByteEqu

TwoByteNoEqu:

nop

bra TestTwoByteEquEnd

TwoByteEqu:

nop

TestTwoByteEquEnd:


;!!!test

.

movlw 0x02

banksel pulseMadrTempH

addwf pulseMadrTempL,F,B

btfsc STATUS, C, A

incf pulseMadrTempH,F,B

WREG

banksel pulseMadrTempH

addwf pulseMadrTempL,F,B

btfsc STATUS, C, A

incf pulseMadrTempH,F,B

banksel byte

incf byteL,F,B

btfsc STATUS, C, A

incf byteH,F,B

24 + 1

banksel byte

incf byteL,F,B

btfsc STATUS, C, A

incf byteH,F,B

btfsc STATUS, C, A

incf byteU,F,B

16 + 16

movf B0,W,A ; B1:B0 +A1:A0-> A1:A0

addwf A0,F,A

movf B1,W,A

addwfc A1,F,A

24 + 16

movf PRODL,W,A

addwf TBLPTRL,F,A

movf PRODH,W,A

addwfc TBLPTRH,F,A

btfsc STATUS, C, A

incf TBLPTRU,F,A

24 + 24

movf B0,W,A ; B2:B1:B0 +A2:A1:A0-> A2:A1:A0

addwf A0,F,A

movf B1,W,A

addwfc A1,F,A

movf B2,W,A

addwfc A2,F,A

32 + 16

banksel QmetrBVRM_in_V_L

movf A0,W,A

addwf QmetrBVRM_in_V_L,F,B

movf A1,W,A

addwfc QmetrBVRM_in_V_H,F,B

btfsc STATUS, C, A

incf QmetrBVRM_in_V_U,F,B

btfsc STATUS, C, A

incf QmetrBVRM_in_V_UU,F,B

32 + 32 ( )

movf BARGB0,W,A ;B3:B2:B1:B0 + tG3:tG2:tG1:tG0 -> tG3:tG2:tG1:tG0

addwf tempG0,F,A

movf BARGB1,W,A

addwfc tempG1,F,A

movf BARGB2,W,A

addwfc tempG2,F,A

movf BARGB3,W,A

addwfc tempG3,F,A

E

banksel byteL

decf byteL,F,B

btfss STATUS, C, A

decf byteH,F,B

16 - 8

bsf STATUS,0,A

subwf FSR1L,F,A

btfss STATUS,0,A

decf FSR1H,F,A

16 - 16

bcf STATUS,C,A

movf B0, W, A ;A1:A0 - B1:B0 -> 1:0

subwf A0, F, A

movf B1, W, A

subwfb A1, F, A

32 – 32

bsf STATUS,C,A ;A3:A2:A1:A0 - B3:B2:B1:B0 -> B3:B2:B1:B0

movf AARGB0,W,A

subfwb BARGB0,F,A

movf AARGB1,W,A

subfwb BARGB1,F,A

movf AARGB2,W,A

subfwb BARGB2,F,A

movf AARGB3,W,A

subfwb BARGB3,F,A

16 + 16 EEPROM ( )

arg set UST_rng2Blt1_MADR

movlw high arg

movwf EEMADRH, A

movlw low arg

call EEPROM_Read_3ff, 0

movwf A5, A

movlw low arg+1

call EEPROM_Read_3ff, 0

movwf B0, A


arg set UST_dltRngBlt1_MADR

movlw high arg

movwf EEMADRH, A

movlw low arg

call EEPROM_Read_3ff, 0

movwf B2, A

movlw low arg+1

call EEPROM_Read_3ff, 0

movwf B1, A


movf B2,W,A ; B1:B2 +B0:A5-> B0:A5

addwf A5,F,A

movf B1,W,A

addwfc B0,F,A

4

arg set 600*144

movlw (arg >> 24)

movwf A3,A

movlw upper arg

movwf A2,A

errorlevel -311

movlw high arg

errorlevel +311

movwf A1,A

movlw low arg

movwf A0,A

arg set 600*144

movlw (arg >> 24)

movff WREG,actEnergy2HMwH

movlw upper arg

movff WREG,actEnergy2HMwL

errorlevel -311

movlw high arg

errorlevel +311

movff WREG,actEnergy2HKwH

movlw low arg

movff WREG,actEnergy2HKwL

— — 1

movlw 0x00

iorwf BARGB0,W,A

iorwf BARGB1,W,A

iorwf BARGB2,W,A

iorwf BARGB3,W,A

tstfsz WREG,A ;WREG =0 0

movf A0,W,A

movff A1,A0

movwf A1,A

movff byte1L,A1

movff byte1H,A0


movff byte2L,A5

movff byte2H,B0


call D_cmp ; A0:A1 B0:A5: c=0 -> A0:A1 > B0:A5 c=1 -> A0:A1 =< B0:A5

btfss STATUS,C,0 ; c=1 -> 1 =< 2



USART

USART . .

movlw 3686400*4/9600/64-1

movwf SPBRG1, A

bcf TXSTA1,BRGH,A ; - BRGH TXSTA


bcf TXSTA1,SYNC,A ; - SYNC 0

bcf RCSTA1,RX9,A ; 9 - RX9 1



bsf RCSTA1,SPEN,A ; SPEN 1


bsf RCSTA1,CREN,A ; CREN 1


;----

label_rec:

clrwdt

btfss PIR1,RC1IF ; RCIF - 1

bra label_rec


movf RCREG1, W, A ; 8 RCREG



;----------------------------------- USART-----------------------------------


bcf TXSTA1,TX9,A ; 9 - RX9 1 - 8


bsf TXSTA1,TXEN,A ; - TXEN 1


;? 9 9- TX9D


;------

movwf TXREG1,A ; - TXREG


main:

clrwdt

bra label_rec


END

USART, ,

i equ 0x01

one_one equ 0x10

one_thoo equ 0x11

thoo_one equ 0x12

thoo_thoo equ 0x13



org 0x00

goto _main_init


org 0x08

retfie 1



_main_init:

movlw 4 ;

movwf i,A

lfsr 0, 0x10 ; 100 fsr0 -

;---------------------------------- USART------------------------------

;----

movlw 3686400*4/9600/64-1

movwf SPBRG1, A

bcf TXSTA1,BRGH,A ; - BRGH TXSTA

bcf TXSTA1,SYNC,A ; - SYNC 0

bcf RCSTA1,RX9,A ; 9 - RX9 1

bsf RCSTA1,SPEN,A ; SPEN 1

bsf RCSTA1,CREN,A ; CREN 1


;----

four_recurrence:

label_rec:


clrwdt

btfss PIR1,RC1IF ; RCIF - 1

bra label_rec


movf RCREG1, W, A ; 8 RCREG

movwf POSTINC0,A ; FSR0

decfsz i,F,A ; 4


bra four_recurrence


;---

; bcf 0x014,0,A ;

clrf 0x014, A

movf one_one, W, A

addwf thoo_one, F, A

movf one_thoo, W, A

addwfc thoo_thoo, F, A

bc add_3 ; 1

bra dalshe ;

add_3:

movlw 1

movwf 0x014, A

; bsf 0x014,0,A

dalshe:

; banksel one_one

; movf one_one, W, B

; addwf thoo_one, F, B

; movf one_thoo, W, B

; addwfc thoo_thoo, F, B


;;----------------------------------- USART-----------------------------------

;----

bcf TXSTA1,TX9,A ; 9 - RX9 1 - 8

bsf TXSTA1,TXEN,A ; - TXEN 1

;? 9 9- TX9D

;;------

movf thoo_one,w,A

movwf TXREG1,A ; - TXREG

nop

jdem1:

btfss PIR1,TXIF,A

bra jdem1



movf thoo_thoo,w,A

movwf TXREG1,A

nop

jdem2:

btfss PIR1,TXIF,A

bra jdem2


movf 0x014, w,A

movwf TXREG1,A

nop

jdem3:

btfss TXSTA1,TRMT,A

bra jdem3


main:

clrwdt

bra label_rec


END

USART,

bra main


int: org 8 ;


btfsc PIR1,RCIF,0 ; 0 RCIF

bra RECEIVE ; SCI

no_receive:


btfsc PIR1,TXIF,0 ; 0 TXIF

bra SEND ; SCI

no_send:


retfie 1 ;



RECEIVE: ;


movf RCREG1, W, A ; 8 RCREG

movwf my_b,A

movlw 1

movwf Temp1,A ;


bra no_receive


SEND: ;

movlw 0

cpfsgt Temp1,A ; (Temp1)

bra no_send


movf my_b,WREG,A ; WREG

movwf TXREG1,A ; - TXREG


movlw 0

movwf Temp1,A ;


bra no_send


main:

Temp1 equ 0x01 ;

my_b equ 0x02 ;

movlw 0

movwf Temp1,A ;

;i equ 0x01

;---- usart

movlw 3686400*4/9600/64-1

movwf SPBRG1, A

bcf TXSTA1,BRGH,A ; - BRGH TXSTA

bcf TXSTA1,SYNC,A ; - SYNC 0

bcf RCSTA1,RX9,A ; 9 - RX9 1

bsf RCSTA1,SPEN,A ; SPEN 1

bsf RCSTA1,CREN,A ; CREN 1

bsf TXSTA1,TXEN,A ; - TXEN 1

bsf PIE1,TXIE,A ; usart

bsf PIE1,RCIE,A ; . usart



;------- --------

bcf RCON,IPEN,A ;

bsf INTCON,PEIE,A ;

bsf INTCON, GIE, A

main1:

; movlw 1;

; addwf i,f,A ;


clrwdt;

bra main1


END


------- ------------

movf PCL, W, A ; PCH,PCU PCLATH,PCLATU -

movf kk,W,A ;

addwf PCL, F, A ; kk

rcall smena_poluper_red_01 ; kk 0x01 smena_poluper_red_01

rcall smena_poluper_yeloo_02 ; kk 0x02 smena_poluper_yeloo_02

bra nothing_work

bra nothing_work

bra nothing_work

bra nothing_work

bra nothing_work

bra nothing_work

rcall read_polup_red ; kk 0x11 read_polup_red

rcall read_polup_yeloo ; kk 0x12 read_polup_yeloo

----



----------------------

my_macro macro DH, DL ;

movlw DH

movwf TMR0H,A

movlw DL

movwf TMR0L,A ;***

endm



my_macro 0xF1, 0x99 ;

----



---------------------

MPM

prog_MPM:

DW_MPM pauseGnuUst_ADR, 0x6C0, 10, n ;

- - -

n TROUGH_VERSION equ X ( , , TROUGH_VERSION )

1) X > n «»,.. , 10

2) X = n «»,.. , 10

3) X < n «»,.. , 10 .


1 — 0 —


MPM.


softwVersion1MADR 520 0017

softwVersion1MADR 522 0018

softwVersion1MADR 524 00D0

softwVersion1MADR 526 0010

softwVersion1MADR 528 0014

softwVersion1MADR 52A 0015

softwVersion1MADR 52C 0016

softwVersion1MADR 52E 552F

softwVersion1MADR 530 0016

softwVersion1MADR 532 0016

indSofVerMADR 0x534 0B04

indSofVerAbsMADR 0x535 0000

EEPROM

DW_EEPROM D_T_Last_Start_1_ADR, 0x022, 75, 0x00


0 — ( 75) UPI

0xFF – UPI

arg set FC_Start_Mode_ADR

movlw high arg

movwf EEMADRH, A

movlw low arg

movwf EEADR, A

movff A0, EEDATA

call EEPROM_Write_3ff_check, 0

WREG EEDATA


movlw addr_MADR

call EEPROM_Read_3ff

movff EEDATA,byte

WREG EEDATA


arg set PKFlags3_ADR

movlw high arg

movwf EEMADRH,0

movlw low arg

call EEPROM_Read_3ff

movff EEDATA,byte movff WREG,byte movwf A0, A



EEPROM_READ_3FF addr_MADR

movff WREG,byte_L



EEPROM_READ_3FF addr_MADR

movwf byte_L, A

arg set addr_MADR

movlw high arg

movwf EEMADRH, A

movlw low arg

call EEPROM_Read_3ff, 0

movwf A0, A movff WREG,A0

movlw low arg+1

call EEPROM_Read_3ff, 0

movwf A1, A movff WREG,A1


EEPROM_WREAD_3FF addr_MADR

movff WREG,byteL

movff EEDATA,byteH

()

arg set addr_MADR

movlw high arg

movwf EEMADRH, A

movlw low arg

call EEPROM_wRead_3ff, 0

movff WREG, byte_L

movff EEDATA,byte_H

EEPROM_WREAD_3FF addr_MADR

movff WREG, byte_L

movff EEDATA,byte_H


byte_L


EEPROM_WREAD_3FF addr_MADR

movwf byte_L,A

movff EEDATA,byte_H

arg set FC_Start_Mode_ADR

movlw high arg

movwf EEMADRH, A

movlw low arg

movwf EEADR, A

movff A0,EEDATA

call EEPROM_Write_3ff_check, 0

movff byte,EEDATA

clrf EEDATA,0

movlw 0x01

movwf EEDATA,0

movlw high addr_MADR

movwf EEMADRH,0

movlw low addr_MADR

movwf EEADR,0

call EEPROM_Write_3ff_check

C

arg set anyAdr

movlw high arg

movwf EEMADRH, A

movlw low arg

movwf EEADR, A

movff byte0, EEDATA

call EEPROM_Write_3ff_check, 0

incf EEADR, F, A

movff byte1, EEDATA

call EEPROM_Write_3ff_check, 0

arg set PKFlags3_ADR

movlw high arg

movwf EEMADRH,0

movlw low arg

call EEPROM_Read_3ff

btfsc EEDATA,bite,A

bra metka

/ , ,

arg set ERR_F4_ADR

movlw high arg

movwf EEMADRH,0

movlw low arg

call EEPROM_Read_3ff

bsf EEDATA,maxCntRuchPusk_Err,A

call EEPROM_Write_3ff_check ;

RAM

movlw high FLASH_BUFFER

movwf FSR0H

banksel tblptrLTochn

movff tblptrLTochn,FSR0L

movlw 0x77

movwf INDF0,0

EEPROMa EEPROM

arg set PKFlags3_ADR

movlw high arg

movwf EEMADRH,0

movlw low arg

call EEPROM_Read_3ff


arg set FC_Start_Mode_ADR

movlw high arg

movwf EEMADRH, A

movlw low arg

movwf EEADR, A


call EEPROM_Write_3ff_check, 0



v1.