Forum: Mikrocontroller und Digitale Elektronik Konstanten Speichern und laden


von ragingbull (Gast)


Lesenswert?

Hi

Ich hab folgendes Problem bei einem 8051 Projekt.

Ich möchte mir 9 Konstanten speichern um später wieder darauf zugreifen 
zu können.

;*********************************
;    Name: timer2.a51
;*********************************
;
$include (reg51.inc)
;
      Seg0  EQU    11000000b
      Seg1   EQU    11111001b
      Seg2  EQU    10100100b
      Seg3  EQU    10110000b
      Seg4  EQU    10011001b
      Seg5  EQU    10010010b
      Seg6  EQU    00000010b
      Seg7  EQU    11111000b
      Seg8  EQU    10000000b
      Seg9  EQU    10010000b
      Seg    SEGMENT  CODE
      CSEG   AT    0000h
ANF:    LJMP      0100h
;
;*********************************
;    Interrupt-Vektoren
;*********************************
;
      ORG        000Bh
t0_vec:    LJMP      t0_isr
;
;*********************************
;      Hauptprogramm
;*********************************
;
      RSEG      Seg
Werte:    DB        9d


Wie kann ich Seg1 bis Seg9 in das Label Werte speichern und wie komme 
ich wieder ran?

von Plodderer (Gast)


Lesenswert?

Die konstaten sind ja schon vorhanden.

ldi R19,Seg0

genuegt.

von Plodderer (Gast)


Lesenswert?

Oder

Werte :
db  Seg0, ...

von ragingbull (Gast)


Lesenswert?

Ja ich weis. Ich will diese aber via Register bzw Datapointer abholen um 
diesen zu inkrementieren für den nächsten Wert.

von ragingbull (Gast)


Lesenswert?

1
;*********************************
2
;    Name: timer2.a51
3
;*********************************
4
;    
5
$include (reg51.inc)
6
;
7
      Seg0  EQU    11000000b
8
      Seg1   EQU    11111001b
9
      Seg2  EQU    10100100b
10
      Seg3  EQU    10110000b
11
      Seg4  EQU    10011001b
12
      Seg5  EQU    10010010b
13
      Seg6  EQU    00000010b
14
      Seg7  EQU    11111000b
15
      Seg8  EQU    10000000b
16
      Seg9  EQU    10010000b
17
      Seg    SEGMENT  CODE
18
      CSEG   AT    0000h
19
ANF:    LJMP      0100h
20
;
21
;*********************************
22
;    Interrupt-Vektoren
23
;*********************************
24
;
25
      ORG        000Bh
26
t0_vec:    LJMP      t0_isr
27
;
28
;*********************************
29
;      Hauptprogramm
30
;*********************************
31
;
32
      RSEG      Seg
33
Werte:    DB        Seg1,Seg2,Seg3,Seg4,Seg5,Seg6,Seg7,Seg8,Seg9        
34
      CSEG      AT  0100h
35
ini_t0:    ORL        TMOD,#00000110b
36
      MOV        TH0,#0FFh
37
      MOV        TL0,#0FFh
38
      ORL        TCON,#00010000b
39
      MOV        P0,#Seg0
40
      MOV        P1,#01h
41
      MOV        DPTR,#Werte
42
    
43
44
45
      
46
;
47
ini_int:  SETB      ET0
48
          CLR        TF0
49
          SETB      EA
50
      
51
;
52
endlos:    SJMP      endlos      
53
54
;
55
;*********************************
56
;   Interrupt-Service Routine
57
;*********************************
58
;
59
t0_isr:    MOVX      A,@DPTR
60
           MOV        P1,A
61
           INC        DPTR
62
           RETI
63
;
64
      END


Warum klappt das nicht

Bei MOVX A,@DPTR
Steht im Akku danach 0 drin.

von Alexander S. (schroeder_90)


Lesenswert?

Mein Compiler hat die Werte mal ins EEprom übertragen statt ins Flash 
hier ist ein fehlerquelle wenn du das EEprom nicht beschrieben hast.

von ragingbull (Gast)


Lesenswert?

DAS EEPROM ist nicht beschrieben. Mein Compiler ( Keil ) verschiebt 
Werte nach C:0x0800

Dort stehen auch die Werte von Seg1-Seg9

Nur wenn ich MOV A,@DPTR mache steht im Akku 0h drin.

von ragingbull (Gast)


Lesenswert?

Ich habs

t0_isr:            CLR        A
      MOVC              A,@A+DPTR
      MOV        P0,A
      INC        DPTR


Schon gehts :)

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.