- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 6 von 6

Thema: Kleine Frage zum Speichern auf EEprom

  1. #1
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    28.03.2008
    Ort
    Huntlosen
    Alter
    31
    Beiträge
    391

    Kleine Frage zum Speichern auf EEprom

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hallo,
    ich habe eine Frage zum Abspeichern auf das interne EEprom des Atmels.

    Mal angenommen ich möchte jetzt 3000 Werte abspeichern. Wenn ich das alles auf ein Label speichern möchte, muss ich dann auch 3000 mal 0,0,0,0,0,0 usw. schreiben? Oder geht das auch anders?

    Code:
    '-----------------------------------------------------------------------------------------
    
    '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 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
    
    End
    Das ist nur das beispiel prog von Bascom. Das Prinzip habe ich verstanden, leider aber noch nicht die Details.
    Hunni

  2. #2
    Erfahrener Benutzer Robotik Visionär
    Registriert seit
    26.11.2005
    Ort
    bei Uelzen (Niedersachsen)
    Beiträge
    7.942
    Für 3000 Werte ist das EEPROM vermutlich zu klein. Erst der Mega128 hat 4 kbytes EERPOM. Das würde dann aber auch nur für Byte Werte reichen, oder halt 2000 Integers.

  3. #3
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    28.03.2008
    Ort
    Huntlosen
    Alter
    31
    Beiträge
    391
    ja das war jetzt übertrieben, sollte nur als beispiel sein

  4. #4
    Erfahrener Benutzer Robotik Einstein Avatar von Jaecko
    Registriert seit
    16.10.2006
    Ort
    Lkr. Rottal/Inn
    Alter
    41
    Beiträge
    2.009
    In dem Fall würd ich einfach ne Schleife aufbauen die bis z.B. 3000 zählt und darin dann über WriteEEProm den Wert in den EEProm schreiben; die Zählvariable dabei als Zieladresse verwenden.
    #ifndef MfG
    #define MfG

  5. #5
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    28.03.2008
    Ort
    Huntlosen
    Alter
    31
    Beiträge
    391
    also kann man auch im eeprom modus eine schleife bauen, oder wie soll ich das verstehn. Kann ich 3000 mal writeeeprom schreiben, obwohl ich im eeprom modus nur 3 mal Data 10 , 20 , 30 geschrieben hab.

  6. #6
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    28.03.2008
    Ort
    Huntlosen
    Alter
    31
    Beiträge
    391
    Ahh cool habs gerad verstanden hoffe ich
    Code:
    '-----------------------------------------------------------------------------------------
    
    '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
    
    
    
    
    
    Dim B As Byte
    
    Dim Yes As String * 1
    
    Dim A As Word
    
    
    
    $eeprom
    
    
    
    
    
    
    Label1:
    
    Data 1 , 2 , 3 , 4 , 5
    
    Label2:
    
    Data 10 , 20 , 30 , 40 , 50
    
    
    
    
    
    $data
    
    
    
    
    
    
    For A = 1 To 100
    B = A
    Writeeeprom B , Label1
    Next A
    
    For A = 1 To 200
    
    Readeeprom B , Label1
    Print A
    Next A
    
    End
    Ist ein kleines Beispiel prog von mir

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests