16f628 Eeprom


Closed Thread
Results 1 to 3 of 3

Thread: 16f628 Eeprom

  1. #1
    Join Date
    Mar 2006
    Posts
    12

    Default 16f628 Eeprom

    I am trying to write some data into the EEPROM on a 16F628. It just flat doesn't work. According to the data sheet it should have 128X8 storage. So I wrote a test program to check and every data "slot" reads back 255. Here's the code:
    INCLUDE "modedefs.bas"

    DEFINE OSC 20
    Col VAR BYTE ' Keypad column
    Row VAR BYTE ' Keypad row
    Key VAR BYTE ' Key value
    SerPin VAR PortA.0 ' Serial output pin
    KeyCode var byte
    LED VAr PortB.7
    Relay1 var PortA.3
    Relay2 var PortA.4
    CMCON = 7 ' PortA = digital I/O
    VRCON = 0 ' Voltage reference disabled
    OPTION_REG.7 = 0 ' Enable PORTB pull-ups
    SetCode VAR BYTE
    OldCode VAR BYTE[11]
    NewCode VAR BYTE[10]
    LoopCount VAR BYTE
    NumDig VAR BYTE
    Unlock VAR BYTE
    A var byte
    ProgramSwitch var PortA.2
    input programswitch
    Setcode = 1
    unlock = 1
    numdig = 6
    pause 5000
    serout serpin,N9600,[254,1]
    serout serpin,N9600,[254,128]
    serout serpin,N9600,["Power On"]
    Read 0,numdig 'Read number of digits of unlock code from memory
    For loopcount = 1 to numdig ' Read unlock code from memory
    Read loopcount,oldcode[loopcount]
    a = oldcode[loopcount]
    serout serpin,N9600,[254,(192+loopcount)]
    serout serpin,N9600,[(oldcode[loopcount])]
    Next loopcount


    Loop:
    serout serpin,N9600,[254,1]
    for a = 1 to 20
    keycode = a
    write a,keycode
    serout serpin,N9600,[254,128]
    serout serpin,N9600,["location "]
    serout serpin,N9600,[#A]
    serout serpin,N9600,[254,192]
    serout serpin,N9600,["value "]
    serout serpin,N9600,[#keycode]
    Pause 1000
    next
    serout serpin,N9600,[254,1]
    For A = 1 to 20
    read a,keycode
    serout serpin,N9600,[254,128]
    serout serpin,N9600,["read location "]
    serout serpin,N9600,[#A]
    serout serpin,N9600,[254,192]
    serout serpin,N9600,["value "]
    serout serpin,N9600,[#keycode]
    pause 1000
    next
    goto loop
    END

    The VAR's at the top are left over from the "real" program. Any thought's? I would have thought this easier than this but it's really whipping my fanny.
    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    What version of PBP are you using?

    I seem to recall there bas a bug way back in v2.40 or thereabouts that concerned the 16F628's (when they first came out) internal EEPROM. Go check MeLabs website for Revisions...

    I've not looked at your code, but if you do something simple like...

    CounterA var Byte
    LED var PortB.0
    TRISB.0=0
    Start:
    Low LED
    For CounterA=0 to 63
    WRITE CounterA,CounterA
    Next CounterA
    Finish:
    Toggle LED
    Pause 500
    Goto Finish
    End

    When the LED starts to blink, switch-off and remove your PIC, reinsert it into your programmer and read the EEPROM contents (always assuming your programmer/software has that capability). The first 64 bytes of EEPROM should have zero to 63 incrementally written to them.

  3. #3
    Join Date
    Mar 2006
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Thanks

    Patches fixed it.
    Thanks

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. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  3. 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
  4. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59
  5. 16F628 on-chip eeprom problem
    By atomski in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 4th March 2004, 07:43

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