Menu

Writing or setting up EEPROM data

Help
Paul Haug
2017-03-05
2017-03-05
  • Paul Haug

    Paul Haug - 2017-03-05

    Does this code look correct for writing a series of data value to the internal chip eprom, and if so, how do I continue the data on the 2nd & 3rd line.
    It compiles with no errors but unable to add more data on a secound and 3rd line (commented out for now)
    Using Ver 0.96.0 GCB compiler

    'start prgm list
     '''A most simple beginning for crt_drvr display
    '''------------------------------------------------------------------------
    '''
    '''Intial prgm  March 3 2017
    '''PEH
    '''***************************************************************************
        ;Begining of CRT control prgm
        ; March 4 2017
        ; Great Cow Basic ver 096.0
        ;
        ;Chip Settings
               #Chip 16F1847, 32
                #Config OSC = INTOSC, MCLRE = OFF, WDTE = OFF
                    #Option Explicit
    
            dim indxadx as byte    ''''#define indxadx
            dim DataCount as byte     '#define DataCount
    
                #define LoopCounter
    
    ' ----- Configuration
    '
    ' ----- Main body of program commences here.
    '
    'First, setup eeprom memory with data
    '
       indxadx = 0  'set intial location
    
      epwrite indxadx, 1,23,253,12,23,122,211,90,1,2,3,4,77,66,55
                      ;234,111,244,222,111,123,213
                      ;77,32,253,1,2,3,4,5,45,77
    

    Maybe I just need to add "epwrite indxadx" to the 2nd and 3rd line, but will that mess up the indxadx value or will it continue correctly.

     

    Last edit: Paul Haug 2017-03-05
  • Paul Haug

    Paul Haug - 2017-03-05

    Sorry, just a test to add attachments. For those who may wonder what my project is, it is using old crt displays to show analog style clock. Yes, i did buy a preprogramed kit, but now I want to learn GCB and thought this would be a good platform to learn on.
    The ancient 2 inch crt is behide the breadboard.

     

    Last edit: Paul Haug 2017-03-05
  • William Roth

    William Roth - 2017-03-05

    Hi Pau,

    My comments below.

    1. You should be using GCB Ver .97. If .96 is a typo then disregard

    2. Loopcounter is not used. However counters need to change, so
      should be a variable rather than a constant. Use Dim for variables.

    3. There is no need use variable indxadx to write the EEPROM
      But I am guessing that later in code you will use it to "Read"
      the EPPROM so I let it remain. I formatted EPWRITE for ease
      of reading.

      This is how I might do it ( Minus the Comments/corrections)

    'start prgm list
     '''A most simple beginning for crt_drvr display
    '''------------------------------------------------------------------------
    '''
    '''Intial prgm  March 3 2017
    '''PEH
    '''***************************************************************************
        ;Begining of CRT control prgm
        ; March 4 2017
        ; Great Cow Basic ver 097.0
        ;
        ;Chip Settings
        #Chip 16F1847, 32
        #Config OSC = INTOSC, MCLRE = OFF, WDTE = OFF
        #Option Explicit
    
        dim indxadx as byte       ' variable 
        dim DataCount as byte     ' variable 
        dim LoopCounter as Byte   ' variable  
    
    'REM WMR If loopcounter is a variable do not use #define,
    '        use DIM instead 
    'REM WMR #define LoopCounter  
    
    ' ----- Configuration
    '
    ' ----- Main body of program commences here.
    '
    'First, setup eeprom memory with data
    '
    'REM WMR    indxadx = 0  'set intial location
    'REM WMR 
    'REM WMR  epwrite indxadx, 1,23,253,12,23,122,211,90,1,2,3,4,77,66,55
    'REM WMR              ;234,111,244,222,111,123,213
    'REM WMR              ;77,32,253,1,2,3,4,5,45,77
    
    
    '***  Write EEPROM Data (16 per line for ease of formatting) ***
    
      '      index          16 bytes of Data                  
    EPWRITE   0,      1,23,253,12,23,122,211,90,1,2,3,4,77,66,55,234  
    EPWRITE   16,     111,244,222,111,123,213,77,32,253,1,2,3,4,5,45,77
    'EPWRITE  32,  - - - - - - - 16 more - - - - - - - - - 
    'EPWRITE  48,  - - - - - - - 16 more - - - - - - - - -        
    
     
  • William Roth

    William Roth - 2017-03-05

    Maybe this will help with Dim vs #define .

    Picaxe Basic has already "Dimmed" variables for the user. These are B0,B1, W5,W6 .etc. So when you use "Symbol" you are assigning an alternate name to to the already "dimmed" variable. "Symbol" is therefore much like #Define in GCB. Picaxe symbol doe not "dim" variables it simply assigns an Alias.

    Great Cow Basic does not set aside user variables like B0,B1,B2, you must do this with "DIM" or remove "#option Explicit" and allow GCB to automatically dim upon usage in code.

    Example:

    Dim B0 as byte
    Dim B1 as byte 
    #define Counter B0  '// Same as using Symbol in Picaxe Basic
    #define index B1    '// Same as using Symbol in Picaxe Basic
    

    But this is not really code efficient or necessary since we to not really need the B variables. Do this instead

    Dim Counter as byte
    Dim index as byte
    
     
  • William Roth

    William Roth - 2017-03-05

    Great Cow Basic is extremely flexible. Let's say you want to use Picaxe B and W style variables Where W0 equates to B1:B0 ...

    Dim W0 as Word
    Dim B1 ALIAS W0_H as Byte   'High byte represented by _H 
    Dim B0 ALIAS W1 as Byte     'Low Byte
    
    Test: 
    B0 = 0
    B1 = 1 
    '//  W0 is now = 256 
    
    W0 = 257
    '// B0 is now = 1 
    '// B1 is now = 1 
    
     
  • Paul Haug

    Paul Haug - 2017-03-05

    Thanks William, that is just what I needed to get started (since it is the first thing the firmware needs to do). The 8 bit values in eprom will be read out in pairs to be applied to the x and y deflection plates (thru dual DAC and HV drivers). This is a project that I would call "Idon't need this, but it is fun and I will learn GCB".
    .

    You should be using GCB Ver .97. If .96 is a typo then disregard
    Thanks William, you have been a tremendous help in getting to switch over to GCB. I just now updated to Ver .97, thanks for suggesting.

     

    Last edit: Paul Haug 2017-03-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.