READEEPROM/de

From MCS Wiki AVR
< READEEPROM(Difference between revisions)
Jump to: navigation, search
(Funktion)
(Remarks)
 
Line 15: Line 15:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
{| width="604" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="604" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="14%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="14%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
Var
+
var
  
 
| valign="top" width="100%" style="width: 514px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 514px; border: 1px solid rgb(0, 0, 0);" |  
The name of the variable that must be stored
+
Name der Variable in die gespeichert werden soll.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 30: Line 30:
  
 
| valign="top" width="100%" style="width: 514px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 514px; border: 1px solid rgb(0, 0, 0);" |  
The address in the EEPROM where the data must be read from.
+
EEPROM-Adresse an der die Daten gelesen werden sollen.
  
 
|}
 
|}
Line 36: Line 36:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This statement is provided for backwards compatibility with BASCOM-8051.
+
Den Befehl gibt es aus Kompatibilitätsgründen mit BASCOM-8051.
  
You can also use the ERAM variable instead of READEEPROM&nbsp;:
+
Man kann auch ERAM-Variable statt READEEPROM benutzen:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Dim V as Eram Byte 'store in EEPROM
+
Dim V as Eram Byte 'Im EEPROM speichern
  
Dim B As Byte &nbsp;'normal variable
+
Dim B As Byte &nbsp;'normale Variable
  
 
B = 10
 
B = 10
Line 50: Line 50:
 
V = B &nbsp; 'store variable in EEPROM
 
V = B &nbsp; 'store variable in EEPROM
  
B = V &nbsp; 'read from EEPROM
+
B = V &nbsp; 'Liest aus dem EEPROM
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When you use the assignment version, the data types must be equal!
+
Bei Verwendung der Zuweisungsversion müssen die Datentypen übereinstimmen!
 +
 
 +
Laut ATMEL-Datenblatt kann die erste EEPROM-Adresse 0 während eines Rest überschrieben werden und sollte daher NICHT benutzt werden.
  
According to a data sheet from ATMEL, the first location in the EEPROM with address 0, can be overwritten during a reset so don't use it.
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You may also use ERAM variables as indexes. Like&nbsp;:
+
Man kann ERAM-Variablen auch mit Indizes benutzen:
  
 
Dim ar(10) as Eram Byte
 
Dim ar(10) as Eram Byte
Line 66: Line 67:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When you omit the address label in consecutive reads, you must use a new READEEPROM statement. It will not work in a loop:
+
Wenn das Adress-Label in nachfolgenden Reads weggelassen wird dann muss ein neuer READEEPROM-Befehl verwendet werden. Es funktioniert nicht in einer Schleife:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 86: Line 87:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This will not work since there is no pointer maintained. The way it will work&nbsp;:
+
Das funktioniert nicht weil kein Pointer erhalten bleibt.
 
+
Das funktioniert:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
ReadEEprom B , Label1 ' specify label
+
ReadEEprom B , Label1 ' Label angeben
  
ReadEEPROM B ' read next address in EEPROM
+
ReadEEPROM B ' Lesen an der nächsten EEPROM-Adresse
  
ReadEEPROM B ' read next address in EEPROM
+
ReadEEPROM B ' Lesen an der nächsten EEPROM-Adresse
  
 
&nbsp;
 
&nbsp;
  
OR
+
ODER
  
 
&nbsp;
 
&nbsp;
Line 110: Line 111:
 
&nbsp;
 
&nbsp;
  
Eerom_position = 20 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' Set the start read point in eerom
+
Eerom_position = 20 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' Setzen der EEPROM-Startadresse
  
For Next_Read = 1 To 5 Step 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' Set up the bytes to be read from eeprom
+
For Next_Read = 1 To 5 Step 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' Anzahl zu lesender EEPROM-Werte
  
Readeeprom In_byte , eeprom_position &nbsp; &nbsp; &nbsp; &nbsp; ' Use a variable as the pointer to eeprom location
+
Readeeprom In_byte , eeprom_position &nbsp; &nbsp; &nbsp; &nbsp; ' Variable benutzen als Pointer zur EEPROM_Adresse
  
 
Call another_sub_routine &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'
 
Call another_sub_routine &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'
  
Incr Chr_pos_font &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' Now set pointer for next eeprom data byte
+
Incr Chr_pos_font &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' Setzen des Pointers für den nächsten EEPROM-Wert
  
 
Next
 
Next
Line 128: Line 129:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
In the XMEGA, you need to set the mode to mapped&nbsp;:&nbsp;[[CONFIG EEPROM|CONFIG EEPROM]]&nbsp;= MAPPED.
+
Beim XMEGA muss man den Mode mapped setzen:&nbsp;[[CONFIG EEPROM|CONFIG EEPROM]]&nbsp;= MAPPED.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Latest revision as of 01:48, 9 March 2013

Contents

Funktion

Liest einen Wert aus dem EEPROM-Speicher und speichert ihn in einer Variablen.

 

 

Syntax

READEEPROM var , address

 

 

Anmerkungen

var

Name der Variable in die gespeichert werden soll.

Address

EEPROM-Adresse an der die Daten gelesen werden sollen.

 

Den Befehl gibt es aus Kompatibilitätsgründen mit BASCOM-8051.

Man kann auch ERAM-Variable statt READEEPROM benutzen:

 

Dim V as Eram Byte 'Im EEPROM speichern

Dim B As Byte  'normale Variable

B = 10

V = B   'store variable in EEPROM

B = V   'Liest aus dem EEPROM

 

Bei Verwendung der Zuweisungsversion müssen die Datentypen übereinstimmen!

Laut ATMEL-Datenblatt kann die erste EEPROM-Adresse 0 während eines Rest überschrieben werden und sollte daher NICHT benutzt werden.


 

Man kann ERAM-Variablen auch mit Indizes benutzen:

Dim ar(10) as Eram Byte

 

Wenn das Adress-Label in nachfolgenden Reads weggelassen wird dann muss ein neuer READEEPROM-Befehl verwendet werden. Es funktioniert nicht in einer Schleife:

 

Readeeprom B , Label1

Print B

 

Do

Readeeprom B

Print B Loop

Until B = 5

 

Das funktioniert nicht weil kein Pointer erhalten bleibt. Das funktioniert:  

ReadEEprom B , Label1 ' Label angeben

ReadEEPROM B ' Lesen an der nächsten EEPROM-Adresse

ReadEEPROM B ' Lesen an der nächsten EEPROM-Adresse

 

ODER

 

Dim Next_Read as Integer

Dim In_byte as Byte

Dim Eerom_position as Integer

 

Eerom_position = 20                                  ' Setzen der EEPROM-Startadresse

For Next_Read = 1 To 5 Step 1                   ' Anzahl zu lesender EEPROM-Werte

Readeeprom In_byte , eeprom_position         ' Variable benutzen als Pointer zur EEPROM_Adresse

Call another_sub_routine                            '

Incr Chr_pos_font                                    ' Setzen des Pointers für den nächsten EEPROM-Wert

Next


 

 

Beim XMEGA muss man den Mode mapped setzen: CONFIG EEPROM = MAPPED.

 

 

Siehe auch

WRITEEEPROM , $EEPROM

 

 

Assembler

NONE

 

 

Beispiel


'-----------------------------------------------------------------------------------------
'name : eeprom2.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : shows how to use labels with READEEPROM
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' Mikrocontroller
$crystal = 4000000 ' Taktfrequenz
$baud = 19200 ' BAudrate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
'Zunächst einmal Variablen dimensionieren:
Dim B As Byte
Dim Yes As String * 1
 
'Benutzung von readeeprom und writeeprom :
'readeeprom var, address
 
'Eine neue Option ist, ein Label für die Adresse zu benutzen.
'Da die Daten in einer externen Datei sind und nicht im Programm sollten die EEPROM Daten
'als erstes spezifiziert werden. Dies steht im Gegensatz zu den normalen DATA Zeilen welche
'am Endes des Programms spezifiziert werden!!
 
'Zunächst dem Compiler mitteilen, dass wir das EEPROM nutzen wollen um die Daten zu speichern:
$eeprom
 
'Die erzeugte EEP-Datei ist eine Binär-Datei.
'Benutzen Sie $EEPROMHEX um eine Intel Hex-Datei für die Benutzung mit AVR Studio zu erzeugen.
'$eepromhex
 
'LAbel festlegen:
Label1:
Data 1 , 2 , 3 , 4 , 5
Label2:
Data 10 , 20 , 30 , 40 , 50
 
'Zurückschalten zu normalen DATA-Zeilen für den Fall, dass solche verwendet werden:
$data
 
'Der Code oben erzeugt keinen richtigen Object-Code.does not generate real object code
 
'Benutzung der neuen Label Option
Readeeprom B , Label1
Print B 'Ausgabe einer 1
'Nachfolgende Reads lesen die nächsten Werte
'Beim ersten Mal muss das Label angegeben werden damit die Startadresse bekannt ist.
Readeeprom B
Print B 'Ausgabe einer 2
 
Readeeprom B , Label2
Print B 'Ausgabe: 10
Readeeprom B
Print B 'Ausgabe: 20
 
'Funktioniert auch beim Schreiben:
'aber weil es Überschneidungen mit dem Programm geben kann fügen wir hier ein Stop ein.
Input "Ready?" , Yes
B = 100
Writeeeprom B , Label1
B = 101
Writeeeprom B
 
'read it back
Readeeprom B , Label1
Print B 'Ausgabe: 100
'Nachfolgende Reads nächsten den nächsten Wert
'Beim ersten Mal muss das Label angegeben werden damit die Startadresse bekannt ist.
Readeeprom B
Print B 'Ausgabe: 101
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language