logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

bascom i komunikaty w EEPROM'ie

dasioo 09 Gru 2010 19:49 1560 5
REKLAMA
  • #1 8847413
    dasioo
    Poziom 14  
    Witam,
    mam taki problem:
    Wyświetlam w programie kilkadziesiąt rożnych komunikatów, które umieszczone są w pamięci programu. Zaczyna mi brakować miejsca i chciałbym je upchać w EEPROM'ie ale coś mi nie wychodzi.
    Robię to tak:
    $eeprom
    komunikat:
    "kom1" , "kom2" , ...itd
    $data

    nie działa mi to:
    Lookupst(numer_kom,komunikat)

    ponad to nie wiem jak zastąpić takie coś:
    ...
    Lcd "kom34"

    Jak Wy to robicie??
  • REKLAMA
  • #2 8847489
    piotrva
    VIP Zasłużony dla elektroda
    instrukcja readeeprom:
    
    '-----------------------------------------------------------------------------------------
    
    '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
    
    

    i potem sklejanie całego stringa z bajtów, ja bym to tak zrobił
  • REKLAMA
  • #3 8847596
    dasioo
    Poziom 14  
    to więcej mi zajmie pamięci na obsługę tego sklejania jak na gotowy komunikat :(
  • REKLAMA
  • #4 8848308
    manekinen
    Poziom 29  
    Ja komunikaty wrzucałem w 50 znakowego stringa a potem sobie wysyłałem na uart/lcd. A potrzebowałem mieć całość w pamięci bo przed wysłaniem sprawdzałem sumę kontrolną zawartości tego stringa.

    
    Dim Txt As String * 6
    [...]
    $eeprom
    Data "napis1"
    Data "napis2"
    $data
    [...]
    Readeeprom Txt , 0 'adres pierwszego napisu
    Print Txt
    Readeeprom Txt , 7 'adres drugiego napisu
    Print Txt
    
  • REKLAMA
  • #5 9422607
    dasioo
    Poziom 14  
    czy ten zapis:
    Readeeprom Txt , 0
    spowoduje że Bascom sobie przeczyta cały text "napis1" ?
  • #6 9426827
    Konto nie istnieje
    Poziom 1  
REKLAMA