Sida 1 av 1

Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 07:14:24
av e5frog
Program för att simulera CD-växlare till en Volvo-bilstereo, anpassat för 16F877A men jag har 16F628A som borde räcka.

Programmet tar någonstans runt 1,5kB så där är det inga problem, tror inte att den tuggar för mycket RAM heller... verkar inte vara mer än vad 16F877A har iaf.

Schema:
Bild

16F628:
Bild

Något uppenbart är att debug-pinnen måste flyttas/ändras/tas bort, annars är det kanske bara skillnader i hur man ska ställa in allt?

Jag är inte så hemma på PIC-assembler, så om man kunde få lite hjälp med vad som behövs ändras så skulle det vara tacksamt.


Dis-assemblering av .hex-fil med PIC-Disasm v1.6:

Kod: Markera allt

    processor 16F877A
    #include <P16F877A.INC>
    __config 0x3F3A
;   _CP_OFF & _DEBUG_OFF & _WRT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF 
;   & _WDT_OFF & _HS_OSC 

; RAM-Variable
LRAM_0x20 equ 0x20
LRAM_0x21 equ 0x21
LRAM_0x22 equ 0x22
LRAM_0x23 equ 0x23
LRAM_0x24 equ 0x24
LRAM_0x25 equ 0x25
LRAM_0x26 equ 0x26
LRAM_0x27 equ 0x27
LRAM_0x28 equ 0x28
LRAM_0x29 equ 0x29
LRAM_0x2A equ 0x2A
LRAM_0x2B equ 0x2B
LRAM_0x2C equ 0x2C
LRAM_0x2D equ 0x2D
LRAM_0x2E equ 0x2E
LRAM_0x2F equ 0x2F
LRAM_0x30 equ 0x30
LRAM_0x31 equ 0x31
LRAM_0x32 equ 0x32
LRAM_0x33 equ 0x33
LRAM_0x34 equ 0x34
LRAM_0x35 equ 0x35
LRAM_0x36 equ 0x36
LRAM_0x37 equ 0x37
LRAM_0x38 equ 0x38
LRAM_0x39 equ 0x39
LRAM_0x3A equ 0x3A
LRAM_0x3B equ 0x3B
LRAM_0x3C equ 0x3C
LRAM_0x3D equ 0x3D
LRAM_0x3E equ 0x3E
LRAM_0x3F equ 0x3F
LRAM_0x40 equ 0x40
LRAM_0x51 equ 0x51
LRAM_0x52 equ 0x52
LRAM_0x53 equ 0x53
LRAM_0x54 equ 0x54
LRAM_0x56 equ 0x56
LRAM_0x57 equ 0x57
LRAM_0x58 equ 0x58
LRAM_0x59 equ 0x59
LRAM_0x5B equ 0x5B
LRAM_0x5D equ 0x5D
LRAM_0x63 equ 0x63
LRAM_0x64 equ 0x64
LRAM_0x65 equ 0x65
LRAM_0x66 equ 0x66
LRAM_0x67 equ 0x67
LRAM_0x68 equ 0x68
LRAM_0x69 equ 0x69
LRAM_0x6A equ 0x6A
LRAM_0x6B equ 0x6B
LRAM_0x6C equ 0x6C
LRAM_0x6D equ 0x6D
LRAM_0x6E equ 0x6E
LRAM_0x77 equ 0x77
LRAM_0x78 equ 0x78
LRAM_0x79 equ 0x79
LRAM_0x7A equ 0x7A
LRAM_0x7B equ 0x7B
LRAM_0x7F equ 0x7F

; Program

    Org 0x0000

;   Reset-Vector
    MOVLW 0x00           ;   b'00000000'  d'000'
    MOVWF PCLATH         ; !!Bank Program-Page-Select
    GOTO LADR_0x03ED
    NOP
;   Interrupt-Vector
    MOVWF LRAM_0x7F
    SWAPF STATUS,W
    CLRF STATUS
    MOVWF LRAM_0x21
    MOVF PCLATH,W        ; !!Bank Program-Page-Select
    MOVWF LRAM_0x20
    CLRF PCLATH          ; !!Bank Program-Page-Select
    MOVF FSR,W
    MOVWF LRAM_0x22
    MOVF LRAM_0x77,W
    MOVWF LRAM_0x23
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x24
    MOVF LRAM_0x79,W
    MOVWF LRAM_0x25
    MOVF LRAM_0x7A,W
    MOVWF LRAM_0x26
    MOVF LRAM_0x7B,W
    MOVWF LRAM_0x27
    BCF STATUS,IRP
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BTFSS INTCON,INTE
    GOTO LADR_0x001D
    BTFSC INTCON,INTF
    GOTO LADR_0x003A
LADR_0x001D
    MOVLW 0x8C           ;   b'10001100'  d'140'
    MOVWF FSR
    BTFSS INDF,0
    GOTO LADR_0x0023
    BTFSC PIR1,0         ; !!Bank!! PIR1 - PIE1 - EEDATA - EECON1
    GOTO LADR_0x003D
LADR_0x0023
    BTFSS INTCON,T0IE
    GOTO LADR_0x0027
    BTFSC INTCON,T0IF
    GOTO LADR_0x0040
LADR_0x0027
    MOVF LRAM_0x22,W
    MOVWF FSR
    MOVF LRAM_0x23,W
    MOVWF LRAM_0x77
    MOVF LRAM_0x24,W
    MOVWF LRAM_0x78
    MOVF LRAM_0x25,W
    MOVWF LRAM_0x79
    MOVF LRAM_0x26,W
    MOVWF LRAM_0x7A
    MOVF LRAM_0x27,W
    MOVWF LRAM_0x7B
    MOVF LRAM_0x20,W
    MOVWF PCLATH         ; !!Bank Program-Page-Select
    SWAPF LRAM_0x21,W
    MOVWF STATUS
    SWAPF LRAM_0x7F,F
    SWAPF LRAM_0x7F,W
    RETFIE
LADR_0x003A
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x00C3
LADR_0x003D
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x012D
LADR_0x0040
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x011F
LADR_0x0043
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x31           ;   b'00110001'  d'049'  "1"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x31           ;   b'00110001'  d'049'  "1"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0057
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x42           ;   b'01000010'  d'066'  "B"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x46           ;   b'01000110'  d'070'  "F"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0067
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x43           ;   b'01000011'  d'067'  "C"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x31           ;   b'00110001'  d'049'  "1"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x46           ;   b'01000110'  d'070'  "F"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0078
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x46           ;   b'01000110'  d'070'  "F"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0084
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x32           ;   b'00110010'  d'050'  "2"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0098
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x42           ;   b'01000010'  d'066'  "B"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x31           ;   b'00110001'  d'049'  "1"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x31           ;   b'00110001'  d'049'  "1"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x00A8
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x34           ;   b'00110100'  d'052'  "4"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x30           ;   b'00110000'  d'048'  "0"
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x00BC
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    RETLW 0x39           ;   b'00111001'  d'057'  "9"
    RETLW 0x38           ;   b'00111000'  d'056'  "8"
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x00C3
    BTFSS LRAM_0x39,3
    GOTO LADR_0x010B
    BSF LRAM_0x39,1
    BTFSS LRAM_0x39,5
    GOTO LADR_0x00D0
    BSF INTCON,T0IE
    MOVLW 0x15           ;   b'00010101'  d'021'
    MOVWF TMR0           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF TMR0,6           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF LRAM_0x39,5
    GOTO LADR_0x010B
LADR_0x00D0
    MOVF TMR0,W          ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    MOVWF LRAM_0x37
    MOVLW 0x15           ;   b'00010101'  d'021'
    MOVWF TMR0           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF TMR0,6           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF LRAM_0x39,5
    MOVF LRAM_0x37,W
    SUBLW 0x46           ;   b'01000110'  d'070'  "F"
    BTFSC STATUS,C
    GOTO LADR_0x00EB
    MOVF LRAM_0x35,W
    ADDLW 0xFC           ;   b'11111100'  d'252'
    BTFSC STATUS,C
    GOTO LADR_0x00EA
    ADDLW 0x04           ;   b'00000100'  d'004'
    GOTO LADR_0x010F
LADR_0x00E2
    BSF LRAM_0x28,3
    GOTO LADR_0x00EA
LADR_0x00E4
    BSF LRAM_0x28,2
    GOTO LADR_0x00EA
LADR_0x00E6
    BSF LRAM_0x28,1
    GOTO LADR_0x00EA
LADR_0x00E8
    BSF LRAM_0x28,0
    GOTO LADR_0x00EA
LADR_0x00EA
    GOTO LADR_0x00F9
LADR_0x00EB
    MOVF LRAM_0x35,W
    ADDLW 0xFC           ;   b'11111100'  d'252'
    BTFSC STATUS,C
    GOTO LADR_0x00F9
    ADDLW 0x04           ;   b'00000100'  d'004'
    GOTO LADR_0x0117
LADR_0x00F1
    BCF LRAM_0x28,3
    GOTO LADR_0x00F9
LADR_0x00F3
    BCF LRAM_0x28,2
    GOTO LADR_0x00F9
LADR_0x00F5
    BCF LRAM_0x28,1
    GOTO LADR_0x00F9
LADR_0x00F7
    BCF LRAM_0x28,0
    GOTO LADR_0x00F9
LADR_0x00F9
    INCF LRAM_0x35,F
    MOVF LRAM_0x35,W
    SUBLW 0x03           ;   b'00000011'  d'003'
    BTFSC STATUS,C
    GOTO LADR_0x010A
    MOVLW 0x3B           ;   b'00111011'  d'059'  ";"
    ADDWF LRAM_0x36,W
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x28,W
    MOVWF INDF
    CLRF LRAM_0x28
    CLRF LRAM_0x35
    MOVF LRAM_0x36,W
    SUBLW 0x13           ;   b'00010011'  d'019'
    BTFSC STATUS,C
    INCF LRAM_0x36,F
LADR_0x010A
    BCF LRAM_0x39,1
LADR_0x010B
    BCF INTCON,INTF
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x0027
LADR_0x010F
    BSF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    GOTO LADR_0x00E2
    GOTO LADR_0x00E4
    GOTO LADR_0x00E6
    GOTO LADR_0x00E8
LADR_0x0117
    BSF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    GOTO LADR_0x00F1
    GOTO LADR_0x00F3
    GOTO LADR_0x00F5
    GOTO LADR_0x00F7
LADR_0x011F
    BCF INTCON,T0IE
    MOVF LRAM_0x36,W
    SUBLW 0x02           ;   b'00000010'  d'002'
    BTFSC STATUS,C
    GOTO LADR_0x0126
    BSF LRAM_0x39,2
    GOTO LADR_0x0127
LADR_0x0126
    CLRF LRAM_0x36
LADR_0x0127
    CLRF LRAM_0x28
    CLRF LRAM_0x35
    BCF INTCON,T0IF
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x0027
LADR_0x012D
    INCF LRAM_0x38,F
    MOVF LRAM_0x38,W
    SUBLW 0x0A           ;   b'00001010'  d'010'
    BTFSC STATUS,C
    GOTO LADR_0x0141
    BSF LRAM_0x39,0
    CLRF LRAM_0x38
    MOVLW 0x10           ;   b'00010000'  d'016'
    XORWF LRAM_0x39,F
    BTFSS LRAM_0x39,4
    GOTO LADR_0x013D
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    GOTO LADR_0x0141
LADR_0x013D
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
LADR_0x0141
    BCF PIR1,0           ; !!Bank!! PIR1 - PIE1 - EEDATA - EECON1
    BCF PCLATH,3         ; !!Bank Program-Page-Select
    BCF PCLATH,4         ; !!Bank Program-Page-Select
    GOTO LADR_0x0027
LADR_0x0145
    MOVLW 0x30           ;   b'00110000'  d'048'  "0"
    SUBWF LRAM_0x6E,W
    ADDLW 0xC9           ;   b'11001001'  d'201'
    BTFSC STATUS,C
    GOTO LADR_0x018D
    ADDLW 0x37           ;   b'00110111'  d'055'  "7"
    GOTO LADR_0x0190
LADR_0x014C
    CLRF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x014E
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0151
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0154
    MOVLW 0x03           ;   b'00000011'  d'003'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0157
    MOVLW 0x04           ;   b'00000100'  d'004'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x015A
    MOVLW 0x05           ;   b'00000101'  d'005'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x015D
    MOVLW 0x06           ;   b'00000110'  d'006'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0160
    MOVLW 0x07           ;   b'00000111'  d'007'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0163
    MOVLW 0x08           ;   b'00001000'  d'008'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0166
    MOVLW 0x09           ;   b'00001001'  d'009'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0169
    MOVLW 0x0A           ;   b'00001010'  d'010'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x016C
    MOVLW 0x0B           ;   b'00001011'  d'011'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x016F
    MOVLW 0x0C           ;   b'00001100'  d'012'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0172
    MOVLW 0x0D           ;   b'00001101'  d'013'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0175
    MOVLW 0x0E           ;   b'00001110'  d'014'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0178
    MOVLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x017B
    MOVLW 0x0A           ;   b'00001010'  d'010'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x017E
    MOVLW 0x0B           ;   b'00001011'  d'011'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0181
    MOVLW 0x0C           ;   b'00001100'  d'012'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0184
    MOVLW 0x0D           ;   b'00001101'  d'013'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x0187
    MOVLW 0x0E           ;   b'00001110'  d'014'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x018A
    MOVLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x6E
    GOTO LADR_0x018D
LADR_0x018D
    MOVF LRAM_0x6E,W
    MOVWF LRAM_0x78
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0190
    BSF PCLATH,0         ; !!Bank Program-Page-Select
    BCF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    GOTO LADR_0x014C
    GOTO LADR_0x014E
    GOTO LADR_0x0151
    GOTO LADR_0x0154
    GOTO LADR_0x0157
    GOTO LADR_0x015A
    GOTO LADR_0x015D
    GOTO LADR_0x0160
    GOTO LADR_0x0163
    GOTO LADR_0x0166
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x0169
    GOTO LADR_0x016C
    GOTO LADR_0x016F
    GOTO LADR_0x0172
    GOTO LADR_0x0175
    GOTO LADR_0x0178
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x018D
    GOTO LADR_0x017B
    GOTO LADR_0x017E
    GOTO LADR_0x0181
    GOTO LADR_0x0184
    GOTO LADR_0x0187
    GOTO LADR_0x018A
LADR_0x01CB
    MOVLW 0x6C           ;   b'01101100'  d'108'  "l"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF INDF,W
    BTFSC STATUS,Z
    GOTO LADR_0x01DE
LADR_0x01D1
    MOVLW 0x06           ;   b'00000110'  d'006'
    MOVWF LRAM_0x78
LADR_0x01D3
    CLRF LRAM_0x77
LADR_0x01D4
    DECFSZ LRAM_0x77,F
    GOTO LADR_0x01D4
    DECFSZ LRAM_0x78,F
    GOTO LADR_0x01D3
    MOVLW 0x7B           ;   b'01111011'  d'123'  "{"
    MOVWF LRAM_0x77
LADR_0x01DA
    DECFSZ LRAM_0x77,F
    GOTO LADR_0x01DA
    DECFSZ INDF,F
    GOTO LADR_0x01D1
LADR_0x01DE
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x01DF
    MOVLW 0x03           ;   b'00000011'  d'003'
    SUBWF LRAM_0x6D,F
    BTFSS STATUS,C
    GOTO LADR_0x01ED
    MOVLW 0x6D           ;   b'01101101'  d'109'  "m"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF INDF,W
    BTFSC STATUS,Z
    GOTO LADR_0x01ED
    GOTO LADR_0x01EB
LADR_0x01EA
    GOTO LADR_0x01EB
LADR_0x01EB
    DECFSZ INDF,F
    GOTO LADR_0x01EA
LADR_0x01ED
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x01EE
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x6C
    CALL LADR_0x01CB
    MOVLW 0x04           ;   b'00000100'  d'004'
    MOVWF LRAM_0x6C
LADR_0x01F7
    MOVLW 0xC7           ;   b'11000111'  d'199'
    MOVWF LRAM_0x6D
    CALL LADR_0x01DF
    DECFSZ LRAM_0x6C,F
    GOTO LADR_0x01F7
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x6C
    CALL LADR_0x01CB
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0204
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    MOVLW 0x03           ;   b'00000011'  d'003'
    MOVWF LRAM_0x6C
LADR_0x020A
    MOVLW 0xC7           ;   b'11000111'  d'199'
    MOVWF LRAM_0x6D
    CALL LADR_0x01DF
    DECFSZ LRAM_0x6C,F
    GOTO LADR_0x020A
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x6C
    CALL LADR_0x01CB
    MOVLW 0xC8           ;   b'11001000'  d'200'
    MOVWF LRAM_0x6D
    CALL LADR_0x01DF
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x021A
    CLRF LRAM_0x6B
LADR_0x021B
    MOVF LRAM_0x6B,W
    SUBLW 0x03           ;   b'00000011'  d'003'
    BTFSS STATUS,C
    GOTO LADR_0x023F
    MOVF LRAM_0x6B,W
    ADDLW 0xFC           ;   b'11111100'  d'252'
    BTFSC STATUS,C
    GOTO LADR_0x023D
    ADDLW 0x04           ;   b'00000100'  d'004'
    GOTO LADR_0x0240
LADR_0x0225
    BTFSS LRAM_0x6A,3
    GOTO LADR_0x0229
    CALL LADR_0x01EE
    GOTO LADR_0x022A
LADR_0x0229
    CALL LADR_0x0204
LADR_0x022A
    GOTO LADR_0x023D
LADR_0x022B
    BTFSS LRAM_0x6A,2
    GOTO LADR_0x022F
    CALL LADR_0x01EE
    GOTO LADR_0x0230
LADR_0x022F
    CALL LADR_0x0204
LADR_0x0230
    GOTO LADR_0x023D
LADR_0x0231
    BTFSS LRAM_0x6A,1
    GOTO LADR_0x0235
    CALL LADR_0x01EE
    GOTO LADR_0x0236
LADR_0x0235
    CALL LADR_0x0204
LADR_0x0236
    GOTO LADR_0x023D
LADR_0x0237
    BTFSS LRAM_0x6A,0
    GOTO LADR_0x023B
    CALL LADR_0x01EE
    GOTO LADR_0x023C
LADR_0x023B
    CALL LADR_0x0204
LADR_0x023C
    GOTO LADR_0x023D
LADR_0x023D
    INCF LRAM_0x6B,F
    GOTO LADR_0x021B
LADR_0x023F
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0240
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BSF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    GOTO LADR_0x0225
    GOTO LADR_0x022B
    GOTO LADR_0x0231
    GOTO LADR_0x0237
LADR_0x0248
    BTFSC LRAM_0x39,1
    GOTO LADR_0x0248
    BCF LRAM_0x39,3
    CLRF LRAM_0x67
LADR_0x024C
    MOVF LRAM_0x66,W
    SUBWF LRAM_0x67,W
    BTFSC STATUS,C
    GOTO LADR_0x0260
    MOVF LRAM_0x67,W
    ADDWF LRAM_0x64,W
    MOVWF FSR
    BCF STATUS,IRP
    BTFSC LRAM_0x65,0
    BSF STATUS,IRP
    MOVF INDF,W
    MOVWF LRAM_0x68
    MOVWF LRAM_0x6E
    CALL LADR_0x0145
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x69
    MOVWF LRAM_0x6A
    CALL LADR_0x021A
    INCF LRAM_0x67,F
    GOTO LADR_0x024C
LADR_0x0260
    MOVF LRAM_0x65,W
    MOVWF LRAM_0x69
    MOVF LRAM_0x64,W
    MOVWF LRAM_0x68
    MOVF LRAM_0x66,W
    MOVWF LRAM_0x6A
    CLRF LRAM_0x6B
    CLRF LRAM_0x6C
LADR_0x0268
    MOVF LRAM_0x6A,W
    SUBWF LRAM_0x6C,W
    BTFSC STATUS,C
    GOTO LADR_0x027A
    MOVF LRAM_0x6C,W
    ADDWF LRAM_0x68,W
    MOVWF FSR
    BCF STATUS,IRP
    BTFSC LRAM_0x69,0
    BSF STATUS,IRP
    MOVF INDF,W
    MOVWF LRAM_0x6D
    MOVWF LRAM_0x6E
    CALL LADR_0x0145
    MOVF LRAM_0x78,W
    XORWF LRAM_0x6B,F
    INCF LRAM_0x6C,F
    GOTO LADR_0x0268
LADR_0x027A
    MOVLW 0x01           ;   b'00000001'  d'001'
    ADDWF LRAM_0x6B,W
    ANDLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x6B
    MOVF LRAM_0x6B,W
    MOVWF LRAM_0x78
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x68
    MOVWF LRAM_0x6E
    CALL LADR_0x0145
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x69
    MOVWF LRAM_0x6A
    CALL LADR_0x021A
    BSF LRAM_0x39,3
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x028A
    MOVF LRAM_0x64,W
    ADDLW 0xF0           ;   b'11110000'  d'240'
    BTFSC STATUS,C
    GOTO LADR_0x02D0
    ADDLW 0x10           ;   b'00010000'  d'016'
    GOTO LADR_0x02D3
LADR_0x0290
    MOVLW 0x30           ;   b'00110000'  d'048'  "0"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x0294
    MOVLW 0x31           ;   b'00110001'  d'049'  "1"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x0298
    MOVLW 0x32           ;   b'00110010'  d'050'  "2"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x029C
    MOVLW 0x33           ;   b'00110011'  d'051'  "3"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02A0
    MOVLW 0x34           ;   b'00110100'  d'052'  "4"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02A4
    MOVLW 0x35           ;   b'00110101'  d'053'  "5"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02A8
    MOVLW 0x36           ;   b'00110110'  d'054'  "6"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02AC
    MOVLW 0x37           ;   b'00110111'  d'055'  "7"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02B0
    MOVLW 0x38           ;   b'00111000'  d'056'  "8"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02B4
    MOVLW 0x39           ;   b'00111001'  d'057'  "9"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02B8
    MOVLW 0x41           ;   b'01000001'  d'065'  "A"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02BC
    MOVLW 0x42           ;   b'01000010'  d'066'  "B"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02C0
    MOVLW 0x43           ;   b'01000011'  d'067'  "C"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02C4
    MOVLW 0x44           ;   b'01000100'  d'068'  "D"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02C8
    MOVLW 0x45           ;   b'01000101'  d'069'  "E"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02CC
    MOVLW 0x46           ;   b'01000110'  d'070'  "F"
    MOVWF LRAM_0x78
    GOTO LADR_0x02D2
    GOTO LADR_0x02D0
LADR_0x02D0
    MOVLW 0x00           ;   b'00000000'  d'000'
    MOVWF LRAM_0x78
LADR_0x02D2
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x02D3
    BCF PCLATH,0         ; !!Bank Program-Page-Select
    BSF PCLATH,1         ; !!Bank Program-Page-Select
    BCF PCLATH,2         ; !!Bank Program-Page-Select
    ADDWF PCL,F          ; !!Program-Counter-Modification
    GOTO LADR_0x0290
    GOTO LADR_0x0294
    GOTO LADR_0x0298
    GOTO LADR_0x029C
    GOTO LADR_0x02A0
    GOTO LADR_0x02A4
    GOTO LADR_0x02A8
    GOTO LADR_0x02AC
    GOTO LADR_0x02B0
    GOTO LADR_0x02B4
    GOTO LADR_0x02B8
    GOTO LADR_0x02BC
    GOTO LADR_0x02C0
    GOTO LADR_0x02C4
    GOTO LADR_0x02C8
    GOTO LADR_0x02CC
LADR_0x02E7
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x02E9
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0043
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x02F7
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x02E9
LADR_0x02F7
    MOVF LRAM_0x2A,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x51
    MOVF LRAM_0x2B,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x52
    MOVF LRAM_0x2C,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x53
    MOVF LRAM_0x2D,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x56
    MOVF LRAM_0x2E,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x57
    MOVF LRAM_0x2F,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x58
    MOVF LRAM_0x30,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x59
    MOVF LRAM_0x32,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x5B
    MOVF LRAM_0x34,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x5D
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x032B
    MOVF LRAM_0x30,W
    SUBLW 0x09           ;   b'00001001'  d'009'
    BTFSC STATUS,C
    GOTO LADR_0x0342
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x30
    INCF LRAM_0x2F,F
    MOVF LRAM_0x2F,W
    SUBLW 0x05           ;   b'00000101'  d'005'
    BTFSC STATUS,C
    GOTO LADR_0x0342
    CLRF LRAM_0x2F
    INCF LRAM_0x2E,F
    MOVF LRAM_0x2E,W
    SUBLW 0x09           ;   b'00001001'  d'009'
    BTFSC STATUS,C
    GOTO LADR_0x0342
    INCF LRAM_0x2D,F
    MOVF LRAM_0x2D,W
    SUBLW 0x05           ;   b'00000101'  d'005'
    BTFSC STATUS,C
    GOTO LADR_0x0342
    CLRF LRAM_0x2D
LADR_0x0342
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0343
    DECFSZ LRAM_0x3A,W
    GOTO LADR_0x038E
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x0347
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0084
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x0355
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x0347
LADR_0x0355
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x035D
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0098
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x036B
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x035D
LADR_0x036B
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0B           ;   b'00001011'  d'011'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x0373
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x00A8
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x0381
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x0373
LADR_0x0381
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0F           ;   b'00001111'  d'015'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    CLRF LRAM_0x3A
    CALL LADR_0x02E7
    MOVLW 0x03           ;   b'00000011'  d'003'
    MOVWF LRAM_0x6C
    CALL LADR_0x01CB
    CALL LADR_0x02E7
    GOTO LADR_0x0393
LADR_0x038E
    CALL LADR_0x02E7
    MOVLW 0x03           ;   b'00000011'  d'003'
    MOVWF LRAM_0x6C
    CALL LADR_0x01CB
    CALL LADR_0x02E7
LADR_0x0393
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x0394
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x0396
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0067
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x03A4
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x0396
LADR_0x03A4
    MOVF LRAM_0x29,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x51
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0C           ;   b'00001100'  d'012'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x03B0
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x03B2
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0057
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x03C0
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x03B2
LADR_0x03C0
    MOVF LRAM_0x29,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x52
    MOVF LRAM_0x2B,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x53
    MOVF LRAM_0x2C,W
    MOVWF LRAM_0x64
    CALL LADR_0x028A
    MOVF LRAM_0x78,W
    MOVWF LRAM_0x54
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x0B           ;   b'00001011'  d'011'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x03D6
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x03D8
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x0078
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x03E6
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x03D8
LADR_0x03E6
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x07           ;   b'00000111'  d'007'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    RETLW 0x00           ;   b'00000000'  d'000'
LADR_0x03ED
    CLRF FSR
    BCF STATUS,IRP
    MOVLW 0x1F           ;   b'00011111'  d'031'
    ANDWF STATUS,F
    MOVLW 0x15           ;   b'00010101'  d'021'
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF TXREG          ; !!Bank!! TXREG - SPBRG - Unimplemented - Unimplemented
    MOVLW 0xA6           ;   b'10100110'  d'166'
    MOVWF RCSTA          ; !!Bank!! RCSTA - TXSTA - Unimplemented - Unimplemented
    MOVLW 0x90           ;   b'10010000'  d'144'
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF RCSTA          ; !!Bank!! RCSTA - TXSTA - Unimplemented - Unimplemented
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF ADCON0,0         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BSF ADCON0,1         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BSF ADCON0,2         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BCF ADCON0,3         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    MOVLW 0x07           ;   b'00000111'  d'007'
    MOVWF CCPR2H         ; !!Bank!! CCPR2H - Unimplemented - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    CLRF LRAM_0x35
    CLRF LRAM_0x36
    CLRF LRAM_0x37
    CLRF LRAM_0x38
    BCF LRAM_0x39,0
    BCF LRAM_0x39,1
    BCF LRAM_0x39,2
    BSF LRAM_0x39,3
    BCF LRAM_0x39,4
    BSF LRAM_0x39,5
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x3A
    MOVLW 0xFF           ;   b'11111111'  d'255'
    MOVWF LRAM_0x63
    MOVLW 0x01           ;   b'00000001'  d'001'
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF PORTB          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTB,1          ; !!Bank!! PORTB - TRISB - PORTB - TRISB
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF ADCON0,0         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BSF ADCON0,1         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BSF ADCON0,2         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BCF ADCON0,3         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF ADCON0,0         ; !!Bank!! ADCON0 - ADCON1 - Unimplemented - Unimplemented
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTE,4          ; !!Bank!! PORTE - TRISE - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF SSPCON,5         ; !!Bank!! SSPCON - SSPSTAT - Unimplemented - Unimplemented
    BCF LRAM_0x63,5
    MOVF LRAM_0x63,W
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF PORTC          ; !!Bank!! PORTC - TRISC - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF LRAM_0x63,4
    MOVF LRAM_0x63,W
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF PORTC          ; !!Bank!! PORTC - TRISC - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF LRAM_0x63,3
    MOVF LRAM_0x63,W
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF PORTC          ; !!Bank!! PORTC - TRISC - Unimplemented - Unimplemented
    MOVLW 0x00           ;   b'00000000'  d'000'
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF SSPCON         ; !!Bank!! SSPCON - SSPSTAT - Unimplemented - Unimplemented
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF SSPCON         ; !!Bank!! SSPCON - SSPSTAT - Unimplemented - Unimplemented
    MOVF TMR0,W          ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    ANDLW 0xC0           ;   b'11000000'  d'192'
    IORLW 0x05           ;   b'00000101'  d'005'
    MOVWF TMR0           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    MOVLW 0xB5           ;   b'10110101'  d'181'
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF T1CON          ; !!Bank!! T1CON - Unimplemented - Unimplemented - Unimplemented
    MOVLW 0x00           ;   b'00000000'  d'000'
    MOVWF LRAM_0x78
    MOVWF T2CON          ; !!Bank!! T2CON - PR2 - Unimplemented - Unimplemented
    MOVLW 0x00           ;   b'00000000'  d'000'
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF T2CON          ; !!Bank!! T2CON - PR2 - Unimplemented - Unimplemented
    MOVLW 0x07           ;   b'00000111'  d'007'
    MOVWF CCPR2H         ; !!Bank!! CCPR2H - Unimplemented - Unimplemented - Unimplemented
    MOVF PORTA,W         ; !!Bank!! PORTA - TRISA - Unimplemented - Unimplemented
    MOVLW 0x10           ;   b'00010000'  d'016'
    MOVWF LRAM_0x77
LADR_0x0449
    DECFSZ LRAM_0x77,F
    GOTO LADR_0x0449
    NOP
    MOVF CCPR2H,W        ; !!Bank!! CCPR2H - Unimplemented - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PIR2,6           ; !!Bank!! PIR2 - PIE2 - EEADR - EECON2
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    CLRF CCP2CON         ; !!Bank!! CCP2CON - Unimplemented - Unimplemented - Unimplemented
    MOVLW 0x01           ;   b'00000001'  d'001'
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    MOVWF LRAM_0x29
    CLRF LRAM_0x2B
    MOVWF LRAM_0x2C
    CLRF LRAM_0x2D
    CLRF LRAM_0x2E
    CLRF LRAM_0x2F
    CLRF LRAM_0x30
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x2A
    CLRF LRAM_0x31
    CLRF LRAM_0x32
    CLRF LRAM_0x33
    MOVLW 0x09           ;   b'00001001'  d'009'
    MOVWF LRAM_0x34
    BCF INTCON,T0IE
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF PIR1,0           ; !!Bank!! PIR1 - PIE1 - EEDATA - EECON1
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    CLRF TMR1H           ; !!Bank!! TMR1H - Unimplemented - EEADRH - Unimplemented
    CLRF TMR1L           ; !!Bank!! TMR1L - PCON - EEDATH - Unimplemented
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF TMR0,6           ; !!Bank!! TMR0 - OPTION_REG - TMR0 - OPTION_REG
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BSF INTCON,INTE
    MOVLW 0xC0           ;   b'11000000'  d'192'
    IORWF INTCON,F
    BSF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
    BCF STATUS,RP0       ; !!Bank Register-Bank(0/1)-Select
    BCF PORTD,2          ; !!Bank!! PORTD - TRISD - Unimplemented - Unimplemented
LADR_0x0471
    BTFSS LRAM_0x39,2
    GOTO LADR_0x053D
    DECFSZ LRAM_0x3B,W
    GOTO LADR_0x0490
    MOVF LRAM_0x3C,W
    SUBLW 0x08           ;   b'00001000'  d'008'
    BTFSS STATUS,Z
    GOTO LADR_0x0490
    CLRF LRAM_0x64
    CLRF LRAM_0x65
LADR_0x047B
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF FSR
    BCF STATUS,IRP
    MOVF LRAM_0x64,W
    ADDWF FSR,F
    MOVF LRAM_0x65,W
    CALL LADR_0x00BC
    MOVWF INDF
    IORLW 0x00           ;   b'00000000'  d'000'
    BTFSC STATUS,Z
    GOTO LADR_0x0489
    INCF LRAM_0x65,F
    INCF LRAM_0x64,F
    GOTO LADR_0x047B
LADR_0x0489
    CLRF LRAM_0x65
    MOVLW 0x4F           ;   b'01001111'  d'079'  "O"
    MOVWF LRAM_0x64
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x66
    CALL LADR_0x0248
    GOTO LADR_0x053B
LADR_0x0490
    DECFSZ LRAM_0x3B,W
    GOTO LADR_0x04D3
    DECFSZ LRAM_0x3C,W
    GOTO LADR_0x04D3
    DECFSZ LRAM_0x3D,W
    GOTO LADR_0x04D3
    MOVF LRAM_0x3E,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x04A4
    MOVF LRAM_0x3F,W
    SUBLW 0x02           ;   b'00000010'  d'002'
    BTFSS STATUS,Z
    GOTO LADR_0x04A4
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x2A
    MOVLW 0x09           ;   b'00001001'  d'009'
    MOVWF LRAM_0x34
    CALL LADR_0x02E7
    CALL LADR_0x02E7
LADR_0x04A4
    MOVF LRAM_0x3E,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x04B0
    DECFSZ LRAM_0x3F,W
    GOTO LADR_0x04B0
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x2A
    MOVLW 0x08           ;   b'00001000'  d'008'
    MOVWF LRAM_0x34
    CALL LADR_0x02E7
    CALL LADR_0x02E7
LADR_0x04B0
    MOVF LRAM_0x3E,F
    BTFSS STATUS,Z
    GOTO LADR_0x04BD
    MOVF LRAM_0x3F,W
    SUBLW 0x08           ;   b'00001000'  d'008'
    BTFSS STATUS,Z
    GOTO LADR_0x04BD
    MOVF LRAM_0x30,F
    BTFSC STATUS,Z
    GOTO LADR_0x04BC
    DECF LRAM_0x30,F
    CALL LADR_0x032B
LADR_0x04BC
    CALL LADR_0x02E7
LADR_0x04BD
    MOVF LRAM_0x3E,F
    BTFSS STATUS,Z
    GOTO LADR_0x04C7
    MOVF LRAM_0x3F,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x04C7
    INCF LRAM_0x30,F
    CALL LADR_0x032B
    CALL LADR_0x02E7
LADR_0x04C7
    MOVF LRAM_0x3E,F
    BTFSS STATUS,Z
    GOTO LADR_0x04D2
    DECFSZ LRAM_0x3F,W
    GOTO LADR_0x04D2
    MOVLW 0x04           ;   b'00000100'  d'004'
    MOVWF LRAM_0x2A
    CLRF LRAM_0x32
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x34
    CALL LADR_0x0343
LADR_0x04D2
    GOTO LADR_0x053B
LADR_0x04D3
    DECFSZ LRAM_0x3B,W
    GOTO LADR_0x04F2
    DECFSZ LRAM_0x3C,W
    GOTO LADR_0x04F2
    MOVF LRAM_0x3D,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x04F2
    MOVF LRAM_0x3E,F
    BTFSS STATUS,Z
    GOTO LADR_0x04E9
    MOVF LRAM_0x3F,W
    SUBLW 0x02           ;   b'00000010'  d'002'
    BTFSS STATUS,Z
    GOTO LADR_0x04E9
    MOVLW 0x04           ;   b'00000100'  d'004'
    MOVWF LRAM_0x2A
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x34
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x32
    CALL LADR_0x0343
LADR_0x04E9
    MOVF LRAM_0x3E,F
    BTFSS STATUS,Z
    GOTO LADR_0x04F1
    MOVF LRAM_0x3F,F
    BTFSS STATUS,Z
    GOTO LADR_0x04F1
    CLRF LRAM_0x32
    CALL LADR_0x02E7
LADR_0x04F1
    GOTO LADR_0x053B
LADR_0x04F2
    DECFSZ LRAM_0x3B,W
    GOTO LADR_0x0508
    MOVF LRAM_0x3C,W
    SUBLW 0x09           ;   b'00001001'  d'009'
    BTFSS STATUS,Z
    GOTO LADR_0x0508
    MOVF LRAM_0x3D,W
    SUBLW 0x09           ;   b'00001001'  d'009'
    BTFSS STATUS,Z
    GOTO LADR_0x0508
    MOVF LRAM_0x2A,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x0504
    MOVLW 0x01           ;   b'00000001'  d'001'
    MOVWF LRAM_0x34
    CALL LADR_0x02E7
    GOTO LADR_0x0507
LADR_0x0504
    DECFSZ LRAM_0x3A,W
    GOTO LADR_0x0507
    CALL LADR_0x0394
LADR_0x0507
    GOTO LADR_0x053B
LADR_0x0508
    DECFSZ LRAM_0x3B,W
    GOTO LADR_0x053A
    DECFSZ LRAM_0x3C,W
    GOTO LADR_0x053A
    MOVF LRAM_0x3D,W
    SUBLW 0x03           ;   b'00000011'  d'003'
    BTFSS STATUS,Z
    GOTO LADR_0x053A
    MOVF LRAM_0x3F,W
    SUBLW 0x0A           ;   b'00001010'  d'010'
    BTFSC STATUS,Z
    GOTO LADR_0x0517
    MOVF LRAM_0x3F,W
    SUBLW 0x0B           ;   b'00001011'  d'011'
    BTFSC STATUS,Z
LADR_0x0517
    GOTO LADR_0x0539
    MOVF LRAM_0x3F,W
    MOVWF LRAM_0x2B
    MOVF LRAM_0x40,W
    MOVWF LRAM_0x2C
    MOVLW 0x02           ;   b'00000010'  d'002'
    MOVWF LRAM_0x2A
    MOVLW 0x09           ;   b'00001001'  d'009'
    MOVWF LRAM_0x34
    CLRF LRAM_0x2F
    CLRF LRAM_0x30
    CLRF LRAM_0x2D
    CLRF LRAM_0x2E
    MOVF LRAM_0x3E,F
    BTFSC STATUS,Z
    GOTO LADR_0x052D
    MOVF LRAM_0x3E,W
    MOVWF LRAM_0x29
    CALL LADR_0x03B0
    CALL LADR_0x0394
    CALL LADR_0x03D6
    GOTO LADR_0x0539
LADR_0x052D
    MOVF LRAM_0x3A,W
    SUBLW 0x03           ;   b'00000011'  d'003'
    BTFSS STATUS,Z
    GOTO LADR_0x0534
    CALL LADR_0x03D6
    CLRF LRAM_0x3A
    GOTO LADR_0x0539
LADR_0x0534
    CALL LADR_0x03B0
    CALL LADR_0x0394
    CALL LADR_0x03D6
    MOVLW 0x03           ;   b'00000011'  d'003'
    MOVWF LRAM_0x3A
LADR_0x0539
    GOTO LADR_0x053B
LADR_0x053A
    CALL LADR_0x03D6
LADR_0x053B
    BCF LRAM_0x39,2
    CLRF LRAM_0x36
LADR_0x053D
    BTFSS LRAM_0x39,0
    GOTO LADR_0x0547
    MOVF LRAM_0x2A,W
    SUBLW 0x04           ;   b'00000100'  d'004'
    BTFSS STATUS,Z
    GOTO LADR_0x0547
    CALL LADR_0x02E7
    BCF LRAM_0x39,0
    INCF LRAM_0x30,F
    CALL LADR_0x032B
LADR_0x0547
    GOTO LADR_0x0471
    SLEEP

    End


Någon som kan förbarma sig?

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 10:32:25
av sodjan
Du behöver källkoden. Eller skriva om allt från början.
Eller lägga ner en massa tid på tolknig av din dis-assembly lista.

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 15:59:51
av e5frog
Jo, det hade förstås underlättat men författaren till koden har inte kvar originalkällkoden till denna version och ägnar sig numera åt nyare versioner av bilstereo.

Det finns en listning av en tidigare version som kanske kan vara till nytta, frågan var väl mest om det fanns något som inte funkar i en 16F628A i den applikation som den används för. Vad jag vet just nu är det bara användandet av port D som ska plockas bort eller flyttas - någon blinkande diod med för mig okänd debug information.

Tanken var väl om någon är van vid PIC-assembler kunde kika om det hittas på något som inte passar för PIC:en med mindre minne osv. Kanske valdes 16F877A bara för att den har programmering via SPI?

Olikheter mellan 16F628A och {16F877A}:
Program Memory (KB) 3.5 {14}
RAM Bytes 224 {368}
Data EEPROM (bytes) 128 {256}
Digital Communication Peripherals 1-A/E/USART {1-A/E/USART, 1-MSSP(SPI/I2C)}
Capture/Compare/PWM Peripherals 1 CCP {2 CCP}

Jämför man data memory map så skiljer dessa:
Saknas:
BANK0:
PORTC(07)
PORTD(08)
PORTE(09)
PIR2(0D)
SSPBUF(13)
SSPCON(14)
CCPR2L(1B)
CCPR2H(1C)
CCP2CON(1D)
ADRESH(1E)
ADCON0 <=> CMCON(1F) olika namn

BANK1:
TRISC(87)
TRISD(88)
TRISE(89)
PIE2(8D)
SSPCON2(91)
SSPADD(93)
SSPSTAT(94)
EEDATA(9A)
EEADR(9B)
EECON1 <=> CMCON(9C) olika namn
EECON2 <=> CVRCON(9D) olika namn
ADRESL(9E)
VRCON <=> ADCON1(9F) olika namn

BANK2:
EEDATA(10C)
EEADR(10D)
EEDATH(10E)
EEADRH(10F)
register 16 byte (110-11F)
register 32 byte(150-16F)

BANK3:
EECON1(18C)
EECON2(18D)
register 96 byte (190-1EF)


Här är C-koden för version "0.1", den som är listad tidigare kallas version "2.0".

mbus_emu.h

Kod: Markera allt

#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT                 //Reset when brownout detected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=20000000)
// #use rs232(baud=57600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
mbus_emu.c

Kod: Markera allt

#include "mbus_emu.h"

/* (using 16f788a) */

/* play state */
#define IDLE      0
#define PREPARING 1
#define STOPPED   2
#define PAUSED    3
#define PLAYING   4
#define SPINUP    5
#define FF        6
#define FR        7

#define pState_PLAYING   1
#define pState_PAUSED    2
#define pState_STOPPED   8
#define pState_RANDOM    2

#define MBusMsgLength   20
#define MBusMinimalMsg   2


char retval;  /* temp byte for incoming bits! */
/* Create bit variables so that we can easily set */
/*   individual bits in the retval variable. */
#bit retval_0 = retval.0
#bit retval_1 = retval.1
#bit retval_2 = retval.2
#bit retval_3 = retval.3

struct playdata_struct
{
   int disc, status, trackh, trackl, minh, minl, sech, secl, pflag1, pflag2, pflag3, pflag4;
};
typedef struct playdata_struct PLAY_STRUCT;

PLAY_STRUCT playdata;  /* contains playstatus data */

int MBusBitCnt=0, MBusMsgSize=0; /* bit och byte counter */
int1 MBUSdata=false;
int1 MBUScommand=false;
int1 MBUSenabled=true;
int1 statusled=false;

int runonce=1;

char cBuffer[MBusMsgLength], mBuffer[MBusMsgLength];

/* function declarations */
void mbus1(void);
void mbus0(void);
void rb1_send(int8 data);
int axtoi(char chex);
char itoxi(int ic);
int calc_checksum(char *str, int len);
void mbus_send(char *str, int len);
void rb0_isr();
void bytetimer();
void timer1();
void mbus_command(void);
void mbus_play(void);


void mbus1(void)
{
   output_high(PIN_B1);
   delay_us(1800);
   output_low(PIN_B1);
   delay_us(1000);
}

void mbus0(void)
{
   output_high(PIN_B1);
   delay_us(600);
   output_low(PIN_B1);
   delay_us(2200);
}

void rb1_send(int8 data)
{
   int ic;
   #bit data_0 = data.0
   #bit data_1 = data.1
   #bit data_2 = data.2
   #bit data_3 = data.3

   for (ic=0; ic < 4; ic++)
   {
      switch(ic)
      {
      case 0: if (data_3 == 1) mbus1(); else mbus0(); break;
      case 1: if (data_2 == 1) mbus1(); else mbus0(); break;
      case 2: if (data_1 == 1) mbus1(); else mbus0(); break;
      case 3: if (data_0 == 1) mbus1(); else mbus0(); break;
      }
   }
}

int axtoi(char chex)  /* convert string character to hex */
{
     switch(chex)
     {
        case '0': chex=0; break;
        case '1': chex=1; break;
        case '2': chex=2; break;
        case '3': chex=3; break;
        case '4': chex=4; break;
        case '5': chex=5; break;
        case '6': chex=6; break;
        case '7': chex=7; break;
        case '8': chex=8; break;
        case '9': chex=9; break;
        case 'A': chex=10; break;
        case 'B': chex=11; break;
        case 'C': chex=12; break;
        case 'D': chex=13; break;
        case 'E': chex=14; break;
        case 'F': chex=15; break;
        case 'a': chex=10; break;
        case 'b': chex=11; break;
        case 'c': chex=12; break;
        case 'd': chex=13; break;
        case 'e': chex=14; break;
        case 'f': chex=15; break;
     }
   return(chex);
}

char itoxi(int ic)  /* convert dec to hex (uppercase only) */
{
     switch(ic)
     {
        case 0: return('0'); break;
        case 1: return('1'); break;
        case 2: return('2'); break;
        case 3: return('3'); break;
        case 4: return('4'); break;
        case 5: return('5'); break;
        case 6: return('6'); break;
        case 7: return('7'); break;
        case 8: return('8'); break;
        case 9: return('9'); break;
        case 10: return('A'); break;
        case 11: return('B'); break;
        case 12: return('C'); break;
        case 13: return('D'); break;
        case 14: return('E'); break;
        case 15: return('F'); break;
      }
   return(0);
}


int calc_checksum(char *str, int len)  /* calculate checksum byte */
{
   int chk=0;
   int ic;
   for (ic = 0; ic < len; ic++)
   {
      chk ^= axtoi(str[ic]);
   }
   chk = (chk+1) % 16;
   return (chk);
}

void mbus_send(char *str, int len)
{
   int ic;
   while(MBUSdata) {  } /* wait for any Mbus data to complete */

   MBUSenabled=false;
   for(ic = 0; ic < len; ic++)
   {
      rb1_send(axtoi(str[ic])); /* send data converted from string -> hex */
   }
   rb1_send(axtoi(calc_checksum(str, len))); /* send checksum */

   //delay_us(700); /* wait a while to signal end of command on mbus */
   MBUSenabled=true;
}

#int_ext
void rb0_isr()  /* RB0 H->L indicating Mbus data bit being sent (starting now!) */
{
   if (MBUSenabled)
   {
      MBUSdata=true; /* Mbus incoming data = true */
      enable_interrupts(int_timer0); /* this timer fires if no data is sent for 3 - 4ms */
      set_timer0(0x63);  /* 0x63 is 4ms, 128xPrescale timer @20MHz   0xFF - ( (0,004s / (1/5000000) ) / 128 ) */
      set_timer1(0xf000); /* 0xF253 is 700us, 1xPrescale timer @20MHz 0xFFFF - ( 0,0007s / (1/5000000) ) */
   }                     /* 0xf054 is 800uS, this works better in the real world! */
                           /* 0x8A is 3ms   EE6B is 900uS */
}

#INT_TIMER0
void bytetimer()  /* this interrupt fires if max bytetime has expired! (>3ms) */
{
   disable_interrupts(int_timer0); /* shutdown the timer until next dataset */
   if (MBusMsgSize > MBusMinimalMsg)   /* smallest m-bus command is 3 bytes */
      MBUScommand=true;
   else
   {
      MBusMsgSize=0;
   }
}

/*  axtoi(calc_checksum(cBuffer, (MBusMsgSize-1))));  */


#INT_TIMER1
void timer1() /* determine if Mbus bit !HIGH length equals 1 or 0 */
{
   if (MBUSdata) /* if RB0 H -> L interrupt has fired */
   {
      if (input(PIN_B0) == 0)
      {
         switch(MBusBitCnt)
         {
            case 0: retval_3 = 1; break;
            case 1: retval_2 = 1; break;
            case 2: retval_1 = 1; break;
            case 3: retval_0 = 1; break;
         }
      }
      else
      {
         switch(MBusBitCnt)
         {
            case 0: retval_3 = 0; break;
            case 1: retval_2 = 0; break;
            case 2: retval_1 = 0; break;
            case 3: retval_0 = 0; break;
         }
      }
   MBusBitCnt++;
   if (MBusBitCnt > 3)
   {
      cBuffer[MBusMsgSize]=retval; /* copy databyte to buffer */
      retval=0;
      MBusBitCnt=0;
      if (MBusMsgSize < MBusMsgLength)
         MBusMsgSize++;
   }
   MBUSdata=false;
   }
}

void mbus_fast_fr(void)
{
          if (playdata.secl > 9)
          {
              playdata.secl=1;
              playdata.sech++;
              if (playdata.sech > 5)
              {
                 playdata.sech=0;
                 playdata.minl++;
                 if (playdata.minl > 9)
                 {
                    playdata.minh++;
                    if (playdata.minh > 5)
                    {
                       playdata.minh=0;
                    }
                 }
              }
          }
}

void mbus_play(void)
{            //     012345678901234
   strcpy(mBuffer, "990000100000001");
   mBuffer[2] = itoxi(playdata.status);
   mBuffer[3] = itoxi(playdata.trackh);
   mBuffer[4] = itoxi(playdata.trackl);
   mBuffer[7] = itoxi(playdata.minh);
   mBuffer[8] = itoxi(playdata.minl);
   mBuffer[9] = itoxi(playdata.sech);
   mBuffer[10] = itoxi(playdata.secl);
   mBuffer[12] = itoxi(playdata.pflag2);
   mBuffer[14] = itoxi(playdata.pflag4);
   mbus_send(mBuffer,15);
}

void mbus_change(void)
{
   strcpy(mBuffer, "9B90000000F");
   mBuffer[3] = itoxi(playdata.disc);
   mBuffer[4] = itoxi(playdata.trackh);
   mBuffer[5] = itoxi(playdata.trackl);
   mbus_send(mBuffer,11);
}

void mbus_discinfo(void)
{
   strcpy(mBuffer, "9C001999999F");
   mBuffer[2] = itoxi(playdata.disc);
   mbus_send(mBuffer,12);
}

void mbus_ack(void)
{
   strcpy(mBuffer, "9F00000");  // Ack
   mbus_send(mBuffer,7);
}

void mbus_playing(void)
{
         if (runonce==1)
         {
            strcpy(mBuffer, "992000000000009"); // stop at track 0 00:00
            mbus_send(mBuffer,15);
            strcpy(mBuffer, "9B910000001"); // change disk1 track 0 flags 1
            mbus_send(mBuffer,11);
            //delay_ms(3);
            strcpy(mBuffer, "994000000000009"); // play from track 0 00:00
            mbus_send(mBuffer,15);
            //mbus_send(mBuffer,15);
            runonce=0;

            mbus_play();
            delay_ms(3);
            mbus_play();
         } else
         {
            mbus_play();
            delay_ms(3);
            mbus_play();
         }
}

void mbus_command(void)
{

   if ((cBuffer[0]==0x01)&&(cBuffer[1]==0x08))
   {
      strcpy(mBuffer, "98");
      mbus_send(mBuffer,2);
      statusled = !statusled;  // this is a "debug" LED set to blink
      if (statusled)           // at every PING command on m-bus.
            output_high(PIN_D2);
      else
            output_low(PIN_D2);

   } else
   if (cBuffer[0]==0x01 && cBuffer[1]==0x01 && cBuffer[2]==0x01)
   {  /* 111xx */

      if (cBuffer[3]==4 && cBuffer[4]==2 )
      {
         playdata.status=STOPPED; // status = STOP!
         playdata.pflag4=pState_STOPPED+pState_PLAYING;
         mbus_play();
         mbus_play();
      }

       if ( cBuffer[3]==4 && cBuffer[4]==1 )
      {
         playdata.status=STOPPED;
         playdata.pflag4=pState_STOPPED;
         mbus_play();
         mbus_play();
       }

      if (cBuffer[3]==0 && cBuffer[4]==8 )
      {
         if (playdata.secl > 0)
         {
            playdata.secl--;
            mbus_fast_fr();
         }
         mbus_play();
         //mbus_play();
      }

      if (cBuffer[3]==0 && cBuffer[4]==4 )
      {
         playdata.secl++;
         mbus_fast_fr();
         mbus_play();
         //mbus_play();
      }

      if ( cBuffer[3]==0 && cBuffer[4]==1 )
      {
         playdata.status=PLAYING;
         playdata.pflag2=0;
         playdata.pflag4=pState_PLAYING;

         mbus_playing();

      }
   } else
   if (cBuffer[0]==0x01 && cBuffer[1]==0x01 && cBuffer[2]==0x04)
   {  /* 114 play mode (seen 11402804  // 02 = RANDOM (805) = FLAGS) */
      if ( cBuffer[3]==0 && cBuffer[4]==2 )
      {
         playdata.status=PLAYING; //PLAYING; // status = PLAY!
         playdata.pflag4=pState_PLAYING;
         playdata.pflag2=pState_RANDOM;

         mbus_playing();
      }
      if ( cBuffer[3]==0 && cBuffer[4]==0 )
      {
         playdata.pflag2=0;
         mbus_play();
         delay_ms(3);
         mbus_play();
      }
   } else
   if ((cBuffer[0]==0x01)&&(cBuffer[1]==0x09)&&(cBuffer[2]==0x09))
   { /* 199 */
      if (playdata.status==PLAYING)
      {
         playdata.pflag4=pState_PLAYING;
         mbus_play();
      } else
      if (runonce==1)
         mbus_discinfo();
   } else
   if ((cBuffer[0]==0x01)&&(cBuffer[1]==0x01)&&(cBuffer[2]==0x03))
   { /* 113xxxxx change! */
    if (cBuffer[4] == 0x0a || cBuffer[4] == 0x0b)
    {

    } else
    {
      playdata.trackh = cBuffer[4];
      playdata.trackl = cBuffer[5];
      playdata.status=STOPPED;
      playdata.pflag4=pState_STOPPED+pState_PLAYING;
      playdata.sech=0;
      playdata.secl=0;
      playdata.minh=0;
      playdata.minl=0;

      if (cBuffer[3] > 0)
      {
         playdata.disc=cBuffer[3];
         mbus_change();
         mbus_discinfo();
         mbus_ack();
      }
      else
      {

         if (runonce==3)
         {

            mbus_ack();
            runonce=0;
         } else
         {
            mbus_change(); // change
            //delay_ms(2);
            mbus_discinfo();
            mbus_ack();
            runonce=3;
         }
      }
    }
   } else
   {
      mbus_ack();   // unknown command, send Ack!
   }
   MBUScommand=false;
   MBusMsgSize=0;
}

void main()
{
   output_low(PIN_B1); /* initial LOW state for correct m-bus datalevels (does not put any signal on the bus) */
   output_high(PIN_D2); /* set debug LED to ON at dataport D pin 2 */

   /* send 'Ping OK' m-bus command.. this is just what the Volvo SC-805 needs */
   strcpy(mBuffer, "98");
   mbus_send(mBuffer,2);

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   //setup_timer_2(T2_DIV_BY_16,0xFF,16);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   /* initial playstatus */

   playdata.disc=1;
   playdata.trackh=0;
   playdata.trackl=1;
   playdata.minh=0;
   playdata.minl=0;
   playdata.sech=0;
   playdata.secl=0;
   playdata.status=STOPPED;
   playdata.pflag1=0; // not used;
   playdata.pflag2=0; // random flag is here
   playdata.pflag3=0; // not used;
   playdata.pflag4=pState_STOPPED+pState_PLAYING;

   ext_int_edge(H_TO_L);   /* activate High -> Low interrupt trigger */
   enable_interrupts(int_ext);
   disable_interrupts(int_timer0);
   enable_interrupts(int_timer1);
   enable_interrupts(global);

   output_low(PIN_D2); /* set debug LED to OFF, this gives a short flash */
                       /* during startup indicating successful boot :) */

   /* start the main loop where we respond to commands sent by the HU */
   /* commands are beeing recived in realtime by the interrupt services */
   while(1)
   {
      if (MBUScommand)
         mbus_command();
   }
}
Men det kanske är bättre att fråga på något PIC-orienterat forum istället.

Sen kanske det duger med denna version 0.1 om man bara vill kunna spela upp ljud, om den fungerar som den ska.


Fast jag testar väl att modifiera assemblerkoden för 2.0 och ser om den går igenom...

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 16:04:48
av sodjan
Nej, det hela använder så pass få pinnar så en 682A ska inte vara något problem.

> Kanske valdes 16F877A bara för att den har programmering via SPI?

SPI ? Menar du ICSP ?

Prova och bygg koden så får den en första hint om
hur mycket som skiljer.

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 16:12:42
av Glenn
Får man fråga varför du vill gå igenom allt krångel istället för att bara skaffa en PIC16F877A ?

F.ö skulle jag vara EXTREMT intresserad av motsvarande sak för SAAB (9-5) :)

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 17:10:10
av e5frog
Jag har inte kollat hur mycket plats det finns över, tänkte att det kunde vara smidigt att fästa den på bilstereons baksida. 40 pinnars PIC:en känns lite otymplig, sen har jag 16F628 hemma och är allmänt otålig. ;-)

Jag har ett PicBasic Pro program också, som är utvecklad för en Alpine bilstereo (ska vara samma som för Volvos) med tillhörande kommunikation med hemmagjord mp3-spelare, kontrollkoderna är i princip samma denna versionen verkar kunna skicka lite varierande data, på det hela taget så verkar denna versionen bättre utvecklad. Anledningen till att jag fastnade för den var dock för att den visades med exakt samma bilstereo som jag har. Hade det bara varit några enklare grejor att ändra på i programmet så hade jag kunnat testa redan ikväll...

Nu verkar det som om (om det nu är korrekt disassemblerat så det inte är data i detta området) man använder komparator 2 istället för 1 som inte används alls (16F628A har bara en) och även kör BCF och BSF på PORTE av någon anledning, fast ingenting är inkopplat där.


Så jag antar att man kanske skulle göra det enkelt för sig och beställa en 16F877A, testa med PicBASIC Pro versionen medan man väntar och sedan gå vidare om det inte funkar.


Vad har du för stereo i SAABen då?
Det är väl bara att ta en kväll med google och leta.
Jag hittade denna:
http://82.182.142.23/saabradio/index.htm

Annars låter det kanske bättre att koppla in sig på telefon-ingången där den delas upp till stereo och haka på en kabel där.
http://www.mitt-eget.com/saab/faq_audio.shtml

Här fanns ett exempel:
http://jurgar.wordpress.com/2008/07/10/ ... -audio-en/
http://gatoalfa.calipso.com.co/radioMod ... od-AHS.pdf
Verkar inte som man kan ställa bas och diskant när man använder telefoningången, så då är väl kassettexemplet bättre - om man sluppit peta i en kassett.

Verkar som om det är besvärligt med CD-växlar ingången, om det ens finns?

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 17:23:33
av Glenn
Fast 16F887A finns ju i mindre kapslingar också om man vill. dels ytmonterat men även PLCC.

I saaben har jag en AS1, alltså radio+CD+CDväxlarstyrning.. vore nice om man kunde jacka ins ej på den med en MP3-spelare så att man kopplade in sej på linein, och kunde växla låt med knapparna på ratten.

I din första länk där moddar dom ju om så att bandaren (i AS2-stereon) istället används som linein.. nu har jag ingen bandare, men även om jag hade haft det så hade det känns lite B att göra så, plus att det bara blir linein och inte nån styrning.

Re: Anpassa program för 16F877A till 16F628A.

Postat: 17 mars 2011, 17:46:32
av e5frog
Jo, det är ju iofs sant, då är del väl mest oviljan att handla som sätter stopp.
Men är det PDIP så underlättar det, bara att peta i experimentplattan vid test och sen i prototypkortet.

Men jag testar väl den versionen som var gjord för 16F628A så får detta vila så länge.



Aha, då låter det som om det blir komplicerat. ;-)

Vill du bara ha linje in så kunde man anslutit en 3,5mm kontakt med brytare och kopplat in sig på ljudkablarna från CD-växlaren, men det blir ju ingen styrning då förstås. Det är väl inget annat att göra än att googla eller göra allt grovarbete själv med att avlyssna bussen osv.


Bara för sakens skull är här PicBASIC Pro programmet som jag OCR:at och skrivit rent från hittad pdf.

http://classes.cecs.ucf.edu/seecssenior ... hanger.pdf

Kod: Markera allt

'                   MP3 CD Changer Emulator

'--------------------------------------------------------------------
'-- CD Changer Emulator
'--------------------------------------------------------------------
'  Date:
'  		Fall Semester 2002
'  Company:
'   		University of Central Florida
'  Group:
'  		Daniel Gallagher
'  		Ethan Steffens
'  		Tony Trinh
'   
'  Description:
'  		This Pic Basic/assembly code allows for communication
'  		between the head unit and the Atmel. Using the PICl6F628
'  		to interpret the protocol this code allows the necessary
'  		functions to output head unit commands to the Atmel.
'  Comments:
'  		When debugging with Serout2 you the pause statements at
'  		the beginning of each GoSub packet routine needs to be
'  		changed. Make them shorter.
'   
'--------------------------------------------------------------------
'-- Revision History
'--------------------------------------------------------------------
'  1.0  - Initial Coding
'	    Wrote the Wait664 for testing
'  1.1  - Added the TRISA and TRISB settings for the PORT direction
'  	    Included interrupt flag behavior
'  1.1a - Added the Track Command Hex Codes
'  1.1b - Added Interrupt saves and Buffer locations
'  1.1c - Added code for capture of data bits
'   	    Added code to SendByte to Head Unit and SendSerial to Atmel
'   	    IdleStatus Subroutine
'  1.2  - Added to capture 8 bytes
'   	    Checking first byte for action
'   	    Added InitStatus1 and InitStatus2
'  1.3  - Added additional control lines
'   	    Recoded BitLoop and BitNibLoop to accommodate timing issues
'   	    Subroutines CntrlPinSet0 and CntrlPinSet1
'   	    Modified wait times
'  1.4  - Modified the CP1 and CP2 Pins
'   	    Added waitcount and the proper timing for the protocol
'   	    Added First Byte Checking for Idlestatus
'   	    Deleted some commented code, (See v1.3)
'  1.5  - Added waitLoop and waitcountLoop for msec subroutine
'   	    Modified code to reflect the new subroutines
'   	    Added wait times for the InitStatus1 and InitStatus2
'  1.6  - Ported code over to PicBasic Pro
'   	    Code rewritten, further PIC assembly Code (See vl.5)
'   	    Wrote CntrlPinSet0,1 using asm directives
'  1.6a - Pse1, Pse2, Playl, Play2, Nxt, Prev subroutines coded
'  1.6b - Edited GetPollingData to properly get the bits needed
'  1.7  - Added the Serial in alias
'  	    Added the SerOut2 code to communicate with the AtMega161L
'  	    Removed previous defined constants (See 1.6b)
'  1.8  - Asm Interrupt Handler for Pulsin head unit commands
'  	    Changed the DataPin to PORTB.3 Changed the pulseWidth
'  	    routine
'  	    Changed so pulseWidths are stored in a pulseArray
'  1.9  - Back to Polling for Data
'  	    Detection of the Head Unit Polling command working
'  	    Puts only one packet in buttonBytes
'  2.0  - Optimized loops
'  	    ControlPin configured to directly interface with DataPin
'  	    Old transfer packets taken out
'  	    Idle, Init1, Init2 recoded
'  2.1  - Major code reorganization
'  	    Waiting loop put in
'  	    Many if's taken out
'  2.2  - Different clock cycle, 20MHz now
'  2.3  - Got it working again.
'  2.4  - Adding change source function
'  	    - Changed the the track number... didn't work, going back
'  3.0  - Adding Next Track, Previous Track,
'  3.1  - Still adding the functions.. filename wrkmb3_4
'  4.0  - Got the functions working, switching the display for
'  	    all functions
'  4.1  - Implemented NextDisc(folder), PreviousDisc(folder)
'  5.0  - Implemented more functions, HDD spin down
'--------------------------------------------------------------------
'	INCLUDE "MODEDEFS.BAS"  '   Not needed if code does not contain any
 					'   Debug, Serin/out, Shiftin/out, Xin/out
'---------------------------------------
'-- Connections
'---------------------------------------
'   PIC RB3 ‹- From Head Unit MBus Pin 3
'   
'   PIC RA1 = Control Pin (Protocol)
'   
'   PIC R32 -› Atmel
'   	
'---------------------------------------

DataPin		VAR		PORTB.3		'This is the Data Pin for receiving and sending the protocol
ControlPin2		VAR		PORTA.2 		'Control Pin 2
SerialOut		VAR		PORTB.2 		'Used to issue commands to the Atmel
'SerialIn		VAR		PORTB.1		' For future implementation

'-------------
'-- Defines --
'-------------
DEFINE		PULSIN_	MAX 300
DEFINE		OSC		20

'---------------
'-- Variables --
'---------------	
bitBuffer		VAR		BYTE			' To rotate the bits into captureBuffer
tempBuffer		VAR		BYTE			' Temporary byte Buffer to store into captureBuffer
captureBuffer	VAR		BYTE[3]		' Store all the captured bits here
buttonByte1		VAR		BYTE			' First CaptureBuffer Byte
buttonByte2		VAR		BYTE			' Second CaptureBuffer Byte
buttonByte3		VAR		BYTE			' Third CaptureBuffer Byte
pulseWidth		VAR		WORD			' Variable to store pulseWidth
loopValue1		VAR		BYTE
loopValue2		VAR		BYTE
sendBuffer		VAR		BYTE
Meminitchange	VAR		BIT
MemoryP		VAR		BIT			'Used to keep track of which pause
MemoryuP		VAR		BIT			'Used to keep track of play and unpause
Memory1or2		VAR		BIT			'Used to keep track of which unpause
pulseArray		VAR		WORD[24] 
temp			VAR		BYTE
MemTrack		VAR		BYTE

'------------------
'-- Main Program --
'------------------
CMCON = 7	' Added by e5frog, Port A digital I/O
VRCON = 0	' Added by e5frog, Voltage Reference Disabled

TRISA.2 = 1

'  TRISB  ????????????   -   e5frog

Memory1or2 =0
Meminitchange = 0
MemoryP = 0
MemoryuP = 0
MemTrack = $00


Idleloop:

	bitBuffer = $00
	tempBuffer = $00 
	captureBuffer[0] = $00
	captureBuffer[1] = $00
	captureBuffer[2] = $00

	GoSub GetPollingData 	'Wait for a packet
	GoSub Restpac		'Get a packet
	GoSub ScanButtons		'Scan to see if we recognize any buttons
	GoTo Idleloop

	End

'--------------------------------------------
'-- GetPollingData
'--------------------------------------------
'   This funtion is used to capture the bits 
'   1 is a pin pulled low for roughly 1.21 ms
'   0 is a pin pulled Low For roughly 709 us
'--------------------------------------------
GetPollingData:

Waiting:
						'Polls until it gets something
	PulsIn DataPin, 0, pulseArray[0]
	IF (pulseArray[0] != 0) Then Capture		'if pulsin doesn't time out then it polls

	GoTo Waiting
	
	Capture:
		For loopValue1 = 0 to 22
		'changing from 23 to 22 cuz i +1
			PulsIn DataPin, 0, pulseArray[loopValue1 + 1]
		'changed to +1
		Next loopValue1

		Return

'--------------------------------------------
'-- Restpac
'--------------------------------------------
'   This function is used to get the rest of
'   the packet.
'--------------------------------------------
Restpac:

	temp=0

	For loopValue2 = 0 to 2
		For loopValue1 = 0 to 7

			IF (pulseArray[temp] = 0) Then
				captureBuffer[loopValue2] = tempBuffer
				GoTo Ret
			EndIF

			IF (pulseArray[temp] < 500) Then
				bitBuffer = 0
				GoSub FillByte
				GoTo nxtrest
			EndIF

			IF (pulseArray[temp] > 500) Then
				bitBuffer = 1
				GoSub FillByte
			EndIF

nxtrest:
			temp = temp + 1

		Next loopValue1

		captureBuffer[loopValue2] = tempBuffer
		tempBuffer = 0
	Next loopValue2

Ret:
	Return

'--------------------------------------------
'-- FillByte
'--------------------------------------------
'   This funtion is used to get fill the 
'   tempBuffer
'--------------------------------------------
FillByte:
	Asm
		rrf _bitBuffer,1
		rlf _tempBuffer,1
	EndAsm

Return

'--------------------------------------------------------------------
'-- Status & Button Push Packets
'--------------------------------------------------------------------
'   IdleStatus
'   HeadUnit - 18A 11.7ms
'   CD Changer - 982
'--------------------------------------------------------------------
'   InitStatus1
'   Head Unit - 111819 13.71ms
'   CD Changer - 9F005147 8.67ms 9C10115772572 9.51ms 9F005165 8.39ms 
'   9F005165 8.67ms 9F005165 8.39ms 9C10115772572 9.79ms 9A00000000004
'   9.79ms 9D000000005 8.39ms 9B9103000019 8.67ms 9910301022000013
'--------------------------------------------------------------------
'   InitStatus2
'   Head Unit - 111406 15.39ms
'   CD Changer - 991030102200009B 751.89ms 9F005165 8.79ms
'   99203010220009A 751.89ms 9F005165 8.79ms 99203010220009A
'--------------------------------------------------------------------
'   Pse1 (Pause)
'   Head Unit - 111024 22.8906ms
'   CD Changer - 9940101035700015 8.62835ms 9F005268
'--------------------------------------------------------------------
'   Pse2 (Pause)
'   Head Unit - 111024 15.4851ms
'   CD Changer - 9930101035700021
'--------------------------------------------------------------------
'   Playl
'   Head Unit - 111011 18.5952ms
'   CD Changer - 9F001E67 8.62539ms 9940301014300012
'--------------------------------------------------------------------
'   Play2
'   Head Unit - 111011 13.0561ms
'   CD Changer - 9940301014300012
'--------------------------------------------------------------------
'   Nxt
'   Head Unit - 113003102 5.0123ms
'   CD Changer - 9940201001100017 8.62924ms 9F007068	9.83995ms
'   9B920300001C 9.83837ms 9950301000000017 8.62783ms 9F007068 9.84038ms
'   9920301000000018 9.84176ms 9920301000000018
'--------------------------------------------------------------------
'   Prev
'   Head Unit - 113002101 19.2171ms
'   CD Changer - 9F00F060 9.84107ms 9B960200001F 8.63064ms
'   9950201000000018
'--------------------------------------------------------------------
ScanButtons:
		buttonByte1 = captureBuffer[0]
		buttonByte2 = captureBuffer[1]	' Storing the captureBuffer into buttonByte variables
		buttonByte3 = captureBuffer[2]

		'IDLESTATUS
		IF (buttonByte1 == $18) AND (buttonByte2 == $0A) Then
			GoSub IdleStatus
			TRISA.2 = 1
			GoTo RetoMain
		EndIF

		'INITSTATUS1
		IF (buttonByte1 == $11) AND (buttonByte2 == $18) Then
			GoSub InitStatus1
			TRISA.2 = 1
			SerOut2 SerialOut, 16416, ["G"]
			GoTo RetoMain
		EndIF

		'INITSTATUS2
		IF (buttonByte1 == $11) AND (buttonByte2 == $14) Then
			GoSub InitStatus2
			TRISA.2 = 1
			SerOut2 SerialOut, 16416, ["G"]
			GoTo RetoMain
		EndIF

		'Next Track and Previous Track
		IF (buttonByte1 == $11) AND (buttonByte2 == $30) Then
			'PREVIOUS TRACK
			IF (buttonByte3 <= MemTrack) OR (buttonByte3 == $15) OR (buttonByte3 == $14) Then
				GoSub PreviousTrack
				TRISA.2 = 1
				SerOut2 SerialOut, 16416, ["p"]
				MemTrack = $02
				GoTo RetoMain
			EndIF

			'PREVIOUS TRACK
			IF (buttonByte3 <= MemTrack) OR (buttonByte3 == $98) OR (buttonByte3 == $99) Then
				GoSub PreviousTrack
				TRISA.2 = 1
				SerOut2 SerialOut, 16416, ["p"]
				MemTrack = $02
				GoTo RetoMain
			EndIF

			'NEXT TRACK
			IF (buttonByte3 > MemTrack) Then
				GoSub NextTrack
				TRISA.2 = 1
				SerOut2 SerialOut, 16416, ["n"]
				MemTrack = $02
				GoTo RetoMain
			EndIF

		EndIF

		'If statement for Next Disc and Previous Disc
		IF (buttonByte1 == $11) AND ((buttonByte2 &%11110000) == $30) Then

			'PREVIOUS DISC
			IF ((buttonByte2 &%00001111) == 6) OR 
				((buttonByte2 &%00001111) == 5) OR 
				((buttonByte2 &%00001111) == 1) Then
				GoSub PreviousDisc
				TRISA.2 = 1
				SerOut2 SerialOut, 16416, ["D"]
				GoTo RetoMain
			EndIF

			'NEXT DISC
			IF ((buttonByte2 &%00001111) == 2) OR 
				((buttonByte2 &%00001111) == 3) OR 
				((buttonByte2 &%00001111) == 4) Then
				GoSub PreviousDisc
				TRISA.2 = 1
				SerOut2 SerialOut, 16416, ["d"]
				GoTo RetoMain
			EndIF

		EndIF


		'If statement for initchange, pause and unpause
		IF (buttonByte1 == $11) AND (buttonByte2 == $10) Then

			'INITCHANGE1and2
			IF (buttonByte3 == $11) AND (MemoryuP == $00) Then

				IF (Meminitchange == 0) Then
					Meminitchange = 1
					GoTo RetoMain
				EndIF

				IF (Meminitchange == 1) Then
					GoSub InitChange1
					TRISA.2 = 1
					SerOut2 SerialOut, 16416, ["g"]
					Meminitchange = 0
					GoTo RetoMain
				EndIF

			EndIF

			'PAUSE
			IF (buttonByte3 == $24) Then

				IF (MemoryP == $00) Then
					GoSub Pausing1
					TRISA.2 = 1
					GoTo RetoMain
				EndIF
				IF (MemoryP == $01) Then
					GoSub Pausing2
					TRISA.2 = 1
					SerOut2 SerialOut,16416, ["G"]
					GoTo RetoMain
				EndIF

			EndIF

			'UNPAUSE
			IF (buttonByte3 == $11) AND (MemoryuP == $01) Then

				IF (Memory1or2 == $00) Then
					GoSub UnPause1
					TRISA.2 = 1
					GoTo RetoMain
				EndIF
				IF (Memory1or2 == $01) Then
					GoSub UnPause2
					TRISA.2 = 1
					SerOut2 SerialOut,16416, ["g"]
					GoTo RetoMain
				EndIF

			EndIF

		EndIF


RetoMain:
	Return

'-----------------------
'-------Packets---------
'-----------------------

PreviousDisc:
		Pause 50
		sendBuffer = $9F
		GoSub SendByte
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $6F 
		GoSub SendByte 
		sendBuffer = $6A 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $91 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $1B 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $20 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $13 
		GoSub SendByte

		Pause 50

		sendBuffer = $9F 
		GoSub SendByte
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $6F 
		GoSub SendByte 
		sendBuffer = $6A 
		GoSub SendByte

		Pause 9 
		
		sendBuffer = $9B
		GoSub SendByte 
		sendBuffer = $D1
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $1F 
		GoSub SendByte

		Pause 50

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $45 
		GoSub SendByte 
		sendBuffer = $53 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B
		GoSub SendByte 
		sendBuffer = $B1
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $19 
		GoSub SendByte

		Pause 9

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $29 
		GoSub SendByte
		sendBuffer = $59 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B
		GoSub SendByte
		sendBuffer = $C1 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte

		Pause 50

		sendBuffer = $9F
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $29 
		GoSub SendByte 
		sendBuffer = $6C 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $81
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $1C
		GoSub SendByte 

		Pause 50

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $91 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $1C 
		GoSub SendByte

		Pause 9

		sendBuffer = $9F
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		Pause 9

		sendBuffer = $99
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $12 
		GoSub SendByte

		GoSub PreviousTrack	'Added this code


'		sendBuffer = $ 
'		GoSub SendByte 
'		sendBuffer = $ 
'		GoSub SendByte 
'		sendBuffer = $ 
'		GoSub SendByte 
'		sendBuffer = $ 
'		GoSub SendByte 
'		sendBuffer = $
'		GoSub SendByte 
'		sendBuffer = $

'		GoSub SendByte 

		Return


PreviousTrack:
		Pause 50
		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $52 
		GoSub SendByte 
		sendBuffer = $68 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $91 
		GoSub SendByte 
		sendBuffer = $02 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $1A 
		GoSub SendByte

		Pause 9

		GoSub SendByte 
		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $50 
		GoSub SendByte 
		sendBuffer = $20 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $18 
		GoSub SendByte

		Return

NextTrack:
		Pause 50

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $52 
		GoSub SendByte 
		sendBuffer = $68 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $91 
		GoSub SendByte 
		sendBuffer = $02 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $1A 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $50 
		GoSub SendByte 
		sendBuffer = $20 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $18 
		GoSub SendByte

		Return



Pausing1:
		Pause 50
		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $40 
		GoSub SendByte
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $10
		GoSub SendByte 
		sendBuffer = $35 
		GoSub SendByte 
		sendBuffer = $70 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $15 
		GoSub SendByte

		Pause 9

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $52 
		GoSub SendByte 
		sendBuffer = $68 
		GoSub SendByte

		MemoryP = 1				'set to 1 so next time it goes to pausing 2 routine

		Return 

Pausing2:


		Pause 50
		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $30 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $35 
		GoSub SendByte 
		sendBuffer = $70 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $21 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $30
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $10

		GoSub SendByte 
		sendBuffer = $35 
		GoSub SendByte 
		sendBuffer = $70 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $21 
		GoSub SendByte

		MemoryuP = 1 
		MemoryP = 0 		'set to zero so next time program goes to pausing 1 routine

		Return

UnPause1:
		Pause 50
		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $52 
		GoSub SendByte 
		sendBuffer = $68
		GoSub SendByte

		Memory1or2 = 1		'set so next time program goes to unpause2 routine

		Return

Unpause2:
		Pause 50
		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $40 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $35 
		GoSub SendByte 
		sendBuffer = $70 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $15 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $50
		GoSub SendByte 
		sendBuffer = $20 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $18 
		GoSub SendByte

		Memory1or2 = 0		'set to 0 so next time the program will go to unpause 1
		MemoryuP = 0 		'set to 0 so next time the program will go to inital change

		Return

InitChange1:
		Pause 50
		sendBuffer = $99 
		GoSub SendByte 
		sendbuffer = $20 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00
		GoSub SendByte 
		sendBuffer = $00
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $13 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendbuffer = $20 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $10
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $00
		GoSub SendByte
		sendBuffer = $13
		GoSub SendByte

		Pause 9

		sendBuffer = $9F
		GoSub SendByte
		sendBuffer = $00
		GoSub SendByte
		sendBuffer = $6F
		GoSub SendByte 
		sendBuffer = $6A 
		GoSub SendByte

		Pause 9

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $6F 
		GoSub SendByte 
		sendBuffer = $6A 
		GoSub SendByte

		Pause 9

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $92 
		GoSub SendByte
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $19 
		GoSub SendByte

		Pause 9

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $12
		GoSub SendByte

		Pause 9

		sendBuffer = $99 		' adding in seeing if it works for display
		GoSub SendByte 
		sendBuffer = $50 
		GoSub SendByte 
		sendBuffer = $20 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $18 
		GoSub SendByte

		Return

IdleStatus:
		Pause 50
		sendBuffer = $98 
		GoSub SendByte 
		sendBuffer = $2F 
		GoSub SendNibble

		Return

InitStatus1:
		Pause 50
		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $47 
		GoSub SendByte

		PauseUs 8670

		sendBuffer = $9C 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $11 
		GoSub SendByte 
		sendBuffer = $57
		GoSub SendByte 
		sendBuffer = $72 
		GoSub SendByte 
		sendBuffer = $57 
		GoSub SendByte 
		sendBuffer = $2F 
		GoSub SendNibble

		PauseUs 9510

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		PauseUs 8390

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		PauseUs 8670

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		PauseUs 8390

		sendBuffer = $9C 
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte 
		sendBuffer = $11
		GoSub SendByte 
		sendBuffer = $57 
		GoSub SendByte 
		sendBuffer = $72 
		GoSub SendByte 
		sendBuffer = $57 
		GoSub SendByte 
		sendBuffer = $2F

		GoSub SendNibble

		PauseUs 9790

		sendBuffer = $9A 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $4F 
		GoSub SendNibb1e

		PauseUs 9790

		sendBuffer = $9D
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $5F 
		GoSub SendNibble

		PauseUs 8390

		sendBuffer = $9B 
		GoSub SendByte 
		sendBuffer = $91 
		GoSub SendByte 
		sendBuffer = $03 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $19
		GoSub SendByte

		PauseUs 8670

		sendBuffer = $99
		GoSub SendByte
		sendBuffer = $10 'changed from a $10 GoSub SendByte
		sendBuffer = $30 'changed from a $30
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte
		sendBuffer = $22 'changed from a $22
		GoSub SendByte
		sendBuffer = $00 'changed from a $00
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $13 
		GoSub SendByte

		Return

InitStatus2:
		Pause 50
		sendBuffer = $99 
		GoSub SendByte
		sendBuffer = $10 'changed from a $10
		GoSub SendByte
		sendBuffer = $30 'changed from a $30
		GoSub SendByte 
		sendBuffer = $10 
		GoSub SendByte
		sendBuffer = $22 'changed from a $22
		GoSub SendByte
		sendBuffer = $00 'changed from a $00
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $9B 
		GoSub SendByte

		Pause 752

		sendBuffer = $9F 
		GoSub SendByte 
		sendBuffer = $00 
		GoSub SendByte 
		sendBuffer = $51 
		GoSub SendByte 
		sendBuffer = $65 
		GoSub SendByte

		PauseUs 8790

		sendBuffer = $99 
		GoSub SendByte 
		sendBuffer = $20 'changed from a $20 
		GoSub SendByte 
		sendBuffer = $30 'changed from a $30
		GoSub SendByte 
		sendBuffer = $14 
		GoSub SendByte 
		sendBuffer = $22 'changed from a $22
		GoSub SendByte
		sendBuffer = $00 'changed from a $00
		GoSub SendByte 
		sendBuffer = $09 
		GoSub SendByte 
		sendBuffer = $AF 
		GoSub SendNibble

		Return

'----------------------------------------------------
'-- SendByte
'----------------------------------------------------
'   sends a byte to head unit.
'   load byte to sendBuffer before calling subroutine
'----------------------------------------------------
SendByte:
				For loopValue1 = 0 to 7
					Asm
						rlf	_sendBuffer, 1
						btfsc	STATUS, C
						Call	_CntrlPinSet1

						btfss	STATUS, C
						Call	_CntrlPinSet0
					EndAsm
 				Next loopValue1

				Return

'----------------------------------------------------
'-- SendNibble
'----------------------------------------------------
'   sends a byte to head unit.
'   load byte to sendBuffer before calling subroutine
'----------------------------------------------------
SendNibble:

				For loopValue1 = 0 to 3 
					Asm
						rlf	_sendBuffer, 1
						btfsc	STATUS, C
						Call	_CntrlPinSet1

						btfss	STATUS, C
						Call	_CntrlPinSet0
					EndAsm

				Next loopValue1

				Return
'------------------------------------------------
'-- CntrlPinSet0
'------------------------------------------------
'   Sets the RA1 & RA2 Control Pins for Logical 0
'------------------------------------------------
CntrlPinSet0:
'				High	ControlPinl
				Low	ControlPin2

				PauseUs	693

'				Low	ControlPinl
				High	ControlPin2

				PauseUs 2440
				'TRISA.2 =1 
				Return

'------------------------------------------------
'-- CntrlPinSet1
'------------------------------------------------
'   Sets the RA1 & RA2 Control Pins for Logical 1
'------------------------------------------------
CntrlPinSet1:
'				High	ControlPin1
				Low	ControlPin2

				PauseUs 1938

'				Low	ControlPinl
				High	ControlPin2

				PauseUs 1196
				'TRISA.2 =1
				Return


'--------------------------------------------------------------------
'  eof
'--------------------------------------------------------------------
Har inte testat att kompilera än.