Menu

EEPROM program

Help
Gigi
2020-11-23
2021-01-11
1 2 > >> (Page 1 of 2)
  • Gigi

    Gigi - 2020-11-23

    Hello to all,
    you can initialize the EEPROM to programming the chip as MPASM in asm.
    I need a few bytes in precise locations.
    Es. for pic16F628

    ORG 0x2100
    DE 100
    ORG 0x2100+100
    DE 150
    ORG 0x2100+250
    DE 200

     
  • Anobium

    Anobium - 2020-11-23

    Is this the base address of the EEPROM?

     
  • Anobium

    Anobium - 2020-11-23
    #chip 16f628
    
     TableLoc = 2
        ReadTable TestDataSource, TableLoc, SomeVar
    
    
    table TestDataSource  Store Data
    100
    101
    102
    end table
    

    Will yield the following. Change your code to handle the number #3 at address 0x00

    ; Data Lookup Tables (data memory)
      ORG 0x2100
    TableTESTDATASOURCE equ 0
      de  3, 100, 101, 102
    
     END
    
     
  • Gigi

    Gigi - 2020-11-23

    Creando la tabella funziona solo che sono indirizzi consecutivi, volevo memorizzare alcuni byte in precisi indirizzi, non si puo fare senza creare una tabella?
    Grazie

     
  • Gigi

    Gigi - 2020-11-23

    By creating the table it only works that they are consecutive addresses, I wanted to store some bytes in specific addresses, can't you do without creating a table?
    Thanks

     
  • Anobium

    Anobium - 2020-11-23

    To answer your initial question re ORG etc the answer is no.

    So, what are you actually trying to achieve? As I am guessing.

     
  • Gigi

    Gigi - 2020-11-23

    Devo salvare dei codici a blocchi di 10~20 byte, inizializzare il primo byte del blocco alla prima accensione e mi bastava scrivere 10 byte. Comunque adesso valuto se creare 10 tabelle o trovare altre souzioni.
    Molte grazie per l'attenzione

     
  • Anobium

    Anobium - 2020-11-23

    Does the 10-20 bytes need to survive a reset (so, you reinit the 10-20 byte block) or does the 10-20 bytes need to be un-altered after a reset?

     
  • Gigi

    Gigi - 2020-11-23

    They must remain after a reset

     
    • Anobium

      Anobium - 2020-11-23

      How much PROGMEM space do have left? So, how much headroom have you left ? Can we use PROGMEM to hold the setup for the EEPROM?

       
  • Gigi

    Gigi - 2020-11-24

    I am working on an old software and I have to make some small changes bringing everything in GCB I have not finished yet but I see that there is little program memory space left.
    How does PROGMEM work?

     
    • Anobium

      Anobium - 2020-11-24

      I just looked at the datasheet. I dont think this is a self write chip so writing to PROGMEM may not work.

      So, do this.

      Create your GCB program. Generate the ASM. Create a second ASM source of your required ORG2100 EEMEM. Then, concat the GCB generated ASM with this EEMEM,ASM and use MPASMX.EXE to link to gen the HEX.

       
  • Gigi

    Gigi - 2020-11-24

    Yes, I think this last solution is the simplest and most practical one to do.

     
    • Anobium

      Anobium - 2020-11-24

      You can automate all this. If you need help then do ask.

       
  • Anobium

    Anobium - 2020-11-24

    I do have a method to generate valid asm!

    I can provide a really simple method to do load the EEMEM. However. you code of +200 will not work as there is on 127 bytes of EEMEM. :-(

    This will require the latest version of the compiler.

    Evan

    ;Program compiled by Great Cow BASIC (0.98.<<>> 2020-11-09 (Windows 64 bit))
    ;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ;check the documentation or email w_cholmondeley at users dot sourceforge dot net.
    
    ;********************************************************************************
    
    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
     LIST p=16F628, r=DEC
    #include <P16F628.inc>
     __CONFIG _CP_OFF & _CPD_OFF & _LVP_OFF & _MCLRE_OFF & _WDTE_OFF & _FOSC_HS
    
    ;********************************************************************************
    
    ;Vectors
        ORG 0
        pagesel BASPROGRAMSTART
        goto    BASPROGRAMSTART
    
    ;********************************************************************************
    
    ;ORG 5
    
        call    INITSYS
    
    ;Start of the main program
    ;Do not change
    ;End of fo not change
    ;Data Lookup Tables (data memory)
        ORG 0x2100
        de   1,2,3
        ORG ( 0x2100 + 50 )
        de   1,2,3
        ORG ( 0x2100 + 100 )
        de   1,2,3
    ;Do not change
        ORG 4
        retfie
        ORG 5
    BASPROGRAMSTART
    ;Call initialisation routines
    ;call   INITSYS
        call    INITSYS
    ;End of fo not change
    ;add you code here.
    ;always this at the end of you user program
    BASPROGRAMEND
    ;sleep
        sleep
    ;goto   BASPROGRAMEND
        goto    BASPROGRAMEND
    
    ;********************************************************************************
    
    ;Source: system.h (117)
    INITSYS
    ;asm showdebug _For_selected_frequency_-_the_external_oscillator_has_been_selected_by_compiler ChipMHz
    ;asm showdebug _Complete_the_chip_setup_of_BSR,ADCs,ANSEL_and_other_key_setup_registers_or_register_bits
    ;Turn off comparator - this is the default setting
    ;CMCON = 7
        movlw   7
        movwf   CMCON
    ;
    ;'Turn off all ports
    ;PORTA = 0
        clrf    PORTA
    ;PORTB = 0
        clrf    PORTB
        return
    
    ;********************************************************************************
    
    
     END
    
     

    Last edit: Anobium 2020-11-24
  • Gigi

    Gigi - 2020-11-24

    Yes you are right the EEPROM is only of 127 byte

    OK, i have try but it doesn't work on my version 0.98.07 RC24 2020-09-06 (Windows 64 bit)

    So in this way I do not disable the comparators automatically and I have to do it manually?

     
    • Anobium

      Anobium - 2020-11-24

      Email me and I will send the new/latest compiler, RC32

       
  • Gigi

    Gigi - 2020-11-24

    I can't find your email address, where can I find it?

     
    • Anobium

      Anobium - 2020-11-24

      I have sent you a personal message (PM)

      Or, if you cannot find (because your contact email is incorrect or Sforge emails get set to spam) then send me a PM.

       
  • Gigi

    Gigi - 2020-11-24

    Sorry but I can't find private messages on this forum !! neither receive them nor send them strange maybe I have something wrong.

     

    Last edit: Gigi 2020-11-24
  • stan cartwright

    stan cartwright - 2020-11-24

    you left click their name and click send message, i think

     
    • Gigi

      Gigi - 2020-11-25

      It doesn't work, I can't send or receive any PMs, I've checked my profile but haven't solved it.

       
  • William Roth

    William Roth - 2021-01-10

    Hi Gigi

    Unfortunately, Great Cow Basic does not have a Directive to embed EEEPROM data into a hex file. However it can be done manually if you will follow these steps. You will need to have MPASMX installed On your PC. The last version comes with MPLABX Ver 5.30

    1. Complete your Great Cow Cow Basic CODE and make sure it works as expected.
    2. Open the ASM for your code
    3. Somewhere around line 14 you will find the following:

       ;Vectors
       ORG    0
       pagesel    BASPROGRAMSTART
       goto   BASPROGRAMSTART
       ORG    4
       retfie
      
           ;***************************
      
    4. Immediately after the code above add the following code.

      ;Embed EEPROM:
      ORG 0x2100
      DE 100
      ORG 0x2100+16
      DE 150
      ORG 0x2100+32
      DE 200
      
      1. You should now have this:
        ;Vectors
        ORG 0
        pagesel BASPROGRAMSTART
        goto    BASPROGRAMSTART
        ORG 4
        retfie
          ;***********************
        ;Embed EEPROM:
         ORG 0x2100
         DE 100
         ORG 0x2100+16
         DE 150
         ORG 0x2100+32
         DE 200
        
    5. Save File. (Do not click on ASM)

    6. Open MPASMX
      A. Uncheck the Case Sensitive box
      B. Click on Browse and find your ASM file and open it
      C. Click on "ASSEMBLE"
      D. If there are no errors you now have a good hex file

    7. Open PICKIT2 GUI
      A. Select your chip
      B. Import the Hex file you just made
      C. Look in the EEPROM Area
      D. You should see the EEPROM Data ( See Attached Image)

     
  • Gigi

    Gigi - 2021-01-11

    Too bad there is no specific directive, however it is very simple to implement when needed.
    Thanks
    Gigi

     
1 2 > >> (Page 1 of 2)

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.