WRITEEEPROM/de
(→Remarks) |
(→See also) |
||
Line 82: | Line 82: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Siehe auch</span> = |
[[READEEPROM]] | [[READEEPROM]] |
Revision as of 01:00, 9 March 2013
Contents |
Funktion
Schreibt den Variableninhalt in den EEPROM-Speicher.
Syntax
WRITEEEPROM var , address
Anmerkungen
var |
Name der Variablen die gespeichert werden soll. |
address |
EEPROM-Adresse an der die Variable gespeichert werden soll.
Eine neue Option ist, dass man einen Label-Namen als Adresse verwenden kann. Siehe Beispiel 2. |
Diesen Befehl gibt es aus Kompatibilitätsgründen mit BASCOM-8051.
Man kann auch schreiben :
Dim V as Eram Byte 'Im EEPROM speichern
Dim B As Byte 'normale Variable
B = 10
V = B 'Variable im EEPROM speichern
Wenn man die Zuweisungs-Version benutzt dann müssen die Datentypen gleich sein!
Laut ATMEL-Datenblatt kann die erste EEPROM-Speicherzelle mit der Adresse 0 bei einem Reset überschrieben werden. Es wird deshalb empfohlen, diese Adresse NICHT zu benutzen.
Aus Sicherheitgründen wird Register R23 auf einen 'magic value' gesetzt bevor Daten in den EEPROM-Speicher geschrieben werden.
Alle Interrupts werden disabled während in den EEPROM-Speicher geschrieben wird. Interrupts werden automatisch wieder enabled wenn die Daten geschrieben sind.
Es ist ratsam, die Brownout-Einheit zu verwenden, die es bei den meistens AVR-Mikrocontrollern gibt. Dadurch wird verhindert, dass Daten in den EEPROM-Speicher geschrieben werden obwohl die Spannung unter den angegebenen Wert sinkt.
Beim XMEGA muss man den Mode auf mapped setzen : CONFIG EEPROM = MAPPED.
Siehe auch
ASM
NONE
Example
'----------------------------------------------------------------------------------------- '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" ' specify the used micro $crystal = 4000000 ' used crystal frequency $baud = 19200 ' use baud rate $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 'first dimension a variable Dim B As Byte Dim Yes As String * 1 'Usage for readeeprom and writeeprom : 'readeeprom var, address 'A new option is to use a label for the address of the data 'Since this data is in an external file and not in the code the eeprom data 'should be specified first. This in contrast with the normal DATA lines which must 'be placed at the end of your program!! 'first tell the compiler that we are using EEPROM to store the DATA $eeprom 'the generated EEP file is a binary file. 'Use $EEPROMHEX to create an Intel Hex file usable with AVR Studio. '$eepromhex 'specify a label Label1: Data 1 , 2 , 3 , 4 , 5 Label2: Data 10 , 20 , 30 , 40 , 50 'Switch back to normal data lines in case they are used $data 'All the code above does not generate real object code 'It only creates a file with the EEP extension 'Use the new label option Readeeprom B , Label1 Print B 'prints 1 'Succesive reads will read the next value 'But the first time the label must be specified so the start is known Readeeprom B Print B 'prints 2 Readeeprom B , Label2 Print B 'prints 10 Readeeprom B Print B 'prints 20 'And it works for writing too : 'but since the programming can interfere we add a stop here Input "Ready?" , Yes B = 100 Writeeeprom B , Label1 B = 101 Writeeeprom B 'read it back Readeeprom B , Label1 Print B 'prints 100 'Succesive reads will read the next value 'But the first time the label must be specified so the start is known Readeeprom B Print B 'prints 101 End
Languages | English • Deutsch |
---|