Re: Egen bygg display har uppdaterings problem (PIC)
Postat: 6 januari 2011, 17:42:54
Ja, men inte med BANKSEL, utan med BANKISEL...
Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Kod: Markera allt
Chk_set_buffer
movf set_buffer, w
sublw h'01' ; Om 01
btfsc STATUS, Z ; D.v.s skippa nästa inst om Z = 1
goto Read_buffer_1 ; Gå till Read_buffer_1 om 01.
goto Read_buffer_2 ; Gå till Read_buffer_2 om 02.
Kod: Markera allt
Read_buffer_1
B1_index_6 ; Index pekare =36 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto B1_index_7 ; Nej, gå till Index_7
movf buffer_1+7, w ; Kopiera buffer_1+7 till w
movwf digit_2 ; Spara w i Digit_1
incf buffer_1, f ; Addera buffer_1 med 1
B1_Index_7
Kod: Markera allt
Read_buffer_2
B2_index_6 ; Index pekare =36 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto B2_index_7 ; Nej, gå till Index_7
movf buffer_2+7, w ; buffer_2+7 till w
movwf digit_2 ; Spara w i Digit_1
incf buffer_2, f ; Addera buffer_2 med 1
B2_index_7
Kod: Markera allt
Movlw Buffer_1 ; kopiera värdet Buffer_1 till w
movwf FSR ; Spara w i pekaren till Buffer_1;
index_6 ; Index pekare =36 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto B1_index_7 ; Nej, gå till Index_7
movf INDF+7, w ; Kopiera INDF+7 till w
movwf digit_2 ; Spara w i Digit_1
incf INDF, f ; Addera INDF med 1
Index_7
Kod: Markera allt
Movlw Buffer_1 ; kopiera värdet Buffer_1 till w
movwf FSR ; Spara w i pekaren till Buffer_1;
bankisel Buffer_1 ; Se till att IRP pekar rätt.
index_6 ; Index pekare =36 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1,
; ...om Ind_check blir 0 hoppa över nästa.
goto B1_index_7 ; Nej, gå till Index_7
movf INDF+7, w ; Kopiera INDF+7 till w
movwf digit_2 ; Spara w i Digit_1
incf INDF, f ; Addera INDF med 1
Index_7
Kod: Markera allt
30 och 31 = Timmar
32 och 33 = Minuter
34 och 35 = Sekunder
36 och 37 = Tion och hundradelar
Kod: Markera allt
Read_buffer
movf set_buffer, w ; Kopiera värdet i set_buffer till w
sublw h'01' ; Om 01 läs buffer_1
btfsc STATUS, Z ; D.v.s skippa nästa inst om Z = 1
goto Read_buffer_2 ; Gå till Read_buffer_2 om 01.
movlw Buffer_1 ; kopiera värdet Buffer_1 till w
movwf FSR ; Spara w i pekaren till Buffer_1;
Bankisel Buffer_1 ; Se till att IRP pekar på Buffer_1.
goto index ; Gå till Index
Read_buffer_2
movlw Buffer_2 ; kopiera värdet Buffer_1 till w
movwf FSR ; Spara w i pekaren till Buffer_1;
Bankisel Buffer_2 ; Se till att IRP pekar på Buffer_2.
;
index
movf INDF, w ; kopiera värdet ur position 1 i buffern till w
movwf Ind_check ; Spara w i Ind_check
movlw h'30' ; Sätt värde 0x30 i w
subwf ind_check,f ; Subtrahera w med Ind_check
btfss STATUS, Z ; Om Z = 0 hoppa över nästa.
goto index_1 ; Nej, gå till Index_1
movf INDF+1, w ; kopiera värdet ur position 2 i buffern till w
movwf digit_7 ; Spara w i Digit_7
incf INDF,f ; Addera värdet ur första position i buffern med 1
goto Read_buffer ; gå till Read_buffer
;
index_1 ; Index pekare =31 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa
goto index_2 ; Nej, gå till Index_2
movf INDF+2, w ; kopiera värdet ur position 3 i buffern till w
movwf digit_6 ; Spara w i Digit_6
incf INDF,f ; Addera värdet ur första position i buffern med 1
goto Read_buffer ; gå till Read_buffer
;
index_2 ; Index pekare =32 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto index_3 ; Nej, gå till Index_3
incf INDF,f ; Addera värdet ur första position i buffern med 1
goto Read_buffer ; gå till Read_buffer
;
index_3 ; Index pekare =33 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto index_4 ; Nej, gå till Index_4
movf INDF+4, w ; kopiera värdet ur position 5 i buffern till w
movwf digit_5 ; Spara w i Digit_5
incf INDF,f ; Addera värdet ur första position i buffern med 1
movf ch_d5,w ; Kopiera ch_d5 till w
movwf temp2 ; Spara w i Temp2
Movf digit_5,w ; Kopiera digit_5 till w
subwf temp2,f ; Subtrahera w med temp2
btfsc STATUS, Z ; Om Z = 0 hoppa över nästa.
goto Read_buffer ; gå till Read_buffer
movlw h'00' ; Sätt värde h'00' i w
movwf T5 ; Sätt T5 låg
goto Read_buffer ; gå till Read_buffer
;
index_4 ; Index pekare =34 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto index_5 ; Nej, gå till Index_5
movf INDF+5, w ; kopiera värdet ur position 6 i buffern till w
movwf digit_4 ; Spara w i Digit_4
incf INDF,f ; Addera värdet ur första position i buffern med 1
movf ch_d4,w ; Kopiera ch_d4 till w
movwf temp2 ; Spara w i Temp2
Movf digit_4,w ; Kopiera digit_4 till w
subwf temp2,f ; Subtrahera w med temp2
btfsc STATUS, Z ; Om Z = 0 hoppa över nästa.
goto Read_buffer ; gå till Read_buffer
movlw h'00' ; Sätt värde h'00' i w
movwf T4 ; Sätt T4 låg
goto Read_buffer ; gå till Read_buffer
;
index_5 ; Index pekare =35 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto index_6 ; Nej, gå till Index_6
movf INDF+6, w ; kopiera värdet ur position 7 i buffern till w
movwf digit_3 ; Spara w i Digit_3
incf INDF,f ; Addera värdet ur första position i buffern med 1
movf ch_d3,w ; Kopiera ch_d3 till w
movwf temp2 ; Spara w i Temp2
Movf digit_3,w ; Kopiera digit_3 till w
subwf temp2,f ; Subtrahera w med temp2
btfsc STATUS, Z ; Om Z = 0 hoppa över nästa.
goto Read_buffer ; gå till Read_buffer
movlw h'00' ; Sätt värde h'00' i w
movwf T3 ; Sätt T3 låg
goto Read_buffer ; gå till Read_buffer
;
index_6 ; Index pekare =36 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto index_7 ; Nej, gå till Index_7
movf INDF+7, w ; kopiera värdet ur position 8 i buffern till w
movwf digit_2 ; Spara w i Digit_2
incf INDF,f ; Addera värdet ur första position i buffern med 1
movf ch_d2,w ; Kopiera ch_d2 till w
movwf temp2 ; Spara w i Temp2
Movf digit_2,w ; Kopiera digit_2 till w
subwf temp2,f ; Subtrahera w med temp2
btfsc STATUS, Z ; Om Z = 0 hoppa över nästa.
goto Read_buffer ; gå till Read_buffer
movlw h'00' ; Sätt värde h'00' i w
movwf T2 ; Sätt T2 låg
goto Read_buffer ; gå till Read_buffer
;
index_7 ; Index pekare =37 ?
decfsz Ind_check, f ; Subtrahera Ind_check med 1, om Ind_check blir 0 hoppa över nästa.
goto Loop ; Nej, gå till Loop
movf INDF+8, w ; kopiera värdet ur position 9 i buffern till w
movwf digit_1 ; Spara w i Digit_1
incf INDF,f ; Addera värdet ur första position i buffern med 1
movf ch_d1,w ; Kopiera ch_d1 till w
movwf temp2 ; Spara w i Temp2
Movf digit_1,w ; Kopiera digit_1 till w
subwf temp2,f ; Subtrahera w med temp2
btfsc STATUS, Z ; Om Z = 0 hoppa över nästa.
goto Loop ; gå till Loop
movlw h'00' ; Sätt värde h'00' i w
movwf T1 ; Sätt T1 låg
goto Loop ; gå till Loop
Kod: Markera allt
MOVLW Buffer_1 + 7 ; beräkna adressen till pos 7 i buffer_1
MOVWF FSR ; Ladda indexregister med adressen till pos 7
MOVF INDF, W ; Hämta pos 7 (eller igentligen 8)...
Kod: Markera allt
MOVLW FSR + 7 ; beräkna adressen till pos 7 i den aktuella bufferten
MOVWF FSR ; Ladda indexregister med adressen till pos 7
MOVF INDF, W ; Hämta pos 7 (eller igentligen 8)...
Kod: Markera allt
MOVLW 7 ; Ladda W med antalet steg frammåt som önskas.
ADDWF FSR, F ; Öka indexpekaren med antalet steg.
MOVF INDF, W ; Hämta den aktuella positionen...