Menu

Problems with EPRead and EPWrite

Help
Fred Stone
2008-05-12
2013-05-30
  • Fred Stone

    Fred Stone - 2008-05-12

    Hi folks,
        Hope all is well with everyone. I've been experimenting with EPWrite and EPRead but can't seem to get things right and I'm hoping someone here can point out what I'm doing wrong. Here's a little test code I've been using:

    ;#################################################################
    #chip 12F683, 8
    #config OSC = INTRC_OSC_NOCLKOUT, MCLR = OFF, PWRT = OFF, CP = OFF, WDT = OFF, BOD = OFF

    Dir GPIO out

    EPWrite(0,20)

    EPRead(0,CountMe)

    for looper = 1 to CountMe
        GPIO.1 = 1
        wait 10 10ms
        GPIO.1 = 0
    next

    end
    ;#################################################################

    This is a quick-and-dirty code but I just wanted to figure out how to store/retrieve data on the EEPROM. Whenever I try to compile this code, I get the following error message:

    Error: GCASM: Symbol EEADRH has not been defined
    Error: GCASM: Symbol EEADRH has not been defined

    I get this error message twice, just as shown here. Probably one for the EPWrite call and one for the EPRead call.

    I have tried both with and without parentheses for EPWrite but that doesn't seem to make any difference.

    BTW: I am already using the updated files from 04/14 so I'm not sure what else might be wrong. I'm sure it's something simple but I'm not catching it.

    Thanks for any help you can offer, and thanks for all the work you folks put into making GCBASIC great.

     
    • Fred Stone

      Fred Stone - 2008-05-12

      Sorry, I made a typo while writing this post. The first line of the code should read:
      #chip 12F683, 4, not 8
      Thanks all.

       
    • Hugh Considine

      Hugh Considine - 2008-05-13

      There's nothing wrong with your code, this is a bug that seems to have resulted from the changes I made to the variable handling code recently. Sorry!

      I've not got the time right now to fix the bug, but you should be able to work around it by adding the line EEADRH = 0 at the start of your program. This is not ideal, and I'll look into the cause and fix it properly as soon as possible (hopefully next weekend).

       
    • Fred Stone

      Fred Stone - 2008-05-13

      Thanks very much. I tried out your suggestion and it worked perfectly.

       
    • Hugh Considine

      Hugh Considine - 2008-06-30

      Bug fixed in the latest updates, no need for the EEADRH = 0 line any more.

      The problem was that GCBASIC was getting confused about the type of the variable used to set the address. In EPRead and EPWrite, EPAddress is a byte variable, made up from EEADR. In ProgramRead and ProgramWrite, it is a word variable, made up from EEADRH and EEADR. GCBASIC was trying to treat EEAddress as a word variable, but as you discovered this causes trouble on the 12F683 and several other chips!

      The update is here: http://gcbasic.sourceforge.net/newfiles/update-nochipdata.zip

       
  • Clint Koehn

    Clint Koehn - 2012-12-11

    I know this is an old topic,  but I'm having the same problem with a PIC18F14K22.   "Symbol not previously defined (EEADRH).

    I have downloaded and installed the latest version.

    Later,
    Clint

     
  • joe rocci

    joe rocci - 2012-12-11

    ckoehn,

    This functionality isn't supported for PIC 18 devices. However, if you're interested, I wrote my own functions to handle this. It was described here:

    https://sourceforge.net/projects/gcbasic/forums/forum/579126/topic/5484814

    Let me know if you want the files.

    Joe

     
  • Clint Koehn

    Clint Koehn - 2012-12-11

    Joe,

    Thanks for your response.  I changed "#chip 18F14k22" to "#chip 18F14K22lin" and it seemed to work.

    If you want to send me your files I'd be glad to have them.  I new to GCBASIC although I have programmed in some dialect of BASIC for 30 yrs.  I made a background send/receive 9600 8 n 1 work with this chip.

    Later,
    Clint

     
  • joe rocci

    joe rocci - 2012-12-11

    ckoehn

    Are you sure it actually "works", or did it just compile without complaining?

    From what I can see in the data sheets, the Flash memory system is the same for both parts and they both conform to the newer PIC18 structure, so it's hard to understand how one would work but not the other.

    Joe

     
  • Clint Koehn

    Clint Koehn - 2012-12-11

    Joe,

    What I did was this.  I use location 0 and 1 to store a word which I used to calibrate a sensor.  I calibrated the sensor, turned off the power and checked the reading.  The reading that used the calibration was right.  In other words the calibration was saved.

    I know what you are saying.  I haven't had time to dig in to the chip data to see what is different.

    Later,
    Clint

     
  • joe rocci

    joe rocci - 2012-12-11

    ckoehn

    Clint
    I apologize…I thought I was reading a thread about reading/writing Flash program memory, not EEProm memory. To clarify, EEProm should work properly, but Flash reads/writes only work for some PIC16 parts.

    Sorry for the confusion
    Joe

     

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.