12f629 Eeprom


Closed Thread
Results 1 to 6 of 6

Thread: 12f629 Eeprom

  1. #1
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44

    Default 12f629 Eeprom

    I have never used EEPROM before and am confusing the **** out of myself reading the data sheet. All I'm trying to do is save and read a couple of variables. One will range from 0-6 while th other would be a 0 or 1. If anyone has a simple code example I would really appriciate the help.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's many ways, but assuming the PBP statements and you want to do it at run-time without having default value in the EEPROM, you need to use WRITE and READ.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Steve that was what I was trying with Write address, value. Maybe I'm confusing myself with the address. On page 49 of the data sheet it also gave a list of requirements and I was getting syntax errors. What I'm trying to do is increment a value using a button and write it to EEPROM and be able to read it.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    O.K. the 12F629 have 128 bytes of EEPROM, so the address range is between 0 and 127. PBP WRITE handle the PIC address for you.

    try this
    Code:
    <font color="#000000">        <font color="#008000">'
            '       Pic Configuration
            '       =================
            </font>@ __CONFIG _INTRC_OSC_NOCLKOUT &amp; _WDT_ON &amp; _PWRTE_ON &amp; _MCLRE_OFF &amp; _BODEN_ON        
            
            <font color="#008000">'
            '       Hardware configuration
            '       ======================
                    '
                    '       I/Os
                    '       ----
                    </font>TRISIO = %11111110  <font color="#008000">' GP0 As output, others TO input
                    
                    '
                    '       Comparator
                    '       ----------
                    </font>CMCON = 7           <font color="#008000">' Disable comparator      
            
            '                      
            '       Hardware assignment
            '       ===================
                    '
                    '       User control
                    '       ------------
                    </font>PB1     <font color="#000080">VAR </font>GPIO.1
                    LED     <font color="#000080">VAR </font>GPIO.0
    
            <font color="#008000">'   
            '       Software variables
            '       ==================
            </font>AddressCounter  <font color="#000080">VAR BYTE
    
            </font><font color="#008000">'
            '       Software/Hardware initialisation
            '       ================================
            </font>AddressCounter = 0
            LED = 0
            <font color="#000080">PAUSE </font>100   <font color="#008000">' osc settle time
            
                    
            '------------------------------&lt; Main program &gt;-----------------------------------
            '
    </font>Start:
            <font color="#000080">WHILE </font>AddressCounter!=128
                <font color="#000080">IF </font>PB1 = 1 <font color="#000080">THEN     
                    WRITE </font>AddressCounter,AddressCounter
                    LED = 1        
                    <font color="#000080">WHILE </font>PB1 : <font color="#000080">WEND
                    PAUSE </font>100
                    LED = 0
                    AddressCounter = AddressCounter + 1
                    <font color="#000080">ENDIF
                WEND
            </font>LED = 1
    
    SpinHere:   
            <font color="#000080">GOTO </font>SpinHere        
            <font color="#008000">'
            '---------------------------------------------------------------------------------
    </font>
    Each time you'll press on the push-button attach to gpio.1, it will write to the EEPROM. Once the EEPROM is full, the LED will stay ON.

    Once done, if i read the pic, the EEPROM show...
    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1609&stc=1&d=117864751 5">

    Sucessfull!
    Attached Images Attached Images  
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Thank you Steve. Let me see where I can go from here.

  6. #6
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Thanks again Steve. It was the address that had me confused and your example cleared it up for me.

    Butch

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. How to define constants that specify eeprom addresses
    By DwayneR in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th December 2009, 04:07
  3. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts