93c46 Eeprom Writing/reading Help


Closed Thread
Results 1 to 4 of 4
  1. #1
    EDWARD's Avatar
    EDWARD Guest

    Default 93c46 Eeprom Writing/reading Help

    I WAS AT THIS Thread just a minute ago and i wish i knew if dark solved his problem.
    http://www.picbasic.co.uk/forum/showthread.php?t=1214

    93c46 datasheet:
    http://leonardo.caltech.edu/~ee5x/ee.../hw6/93c46.pdf


    i have the same problem, but i dont know whether its my reading or writing that is flawed. I am trying to write 3 different byte sized variables to the 93c46. i have attached a pic that shows how it is all connected. I dont think that there are any pull up resistors on the CLK or CS line, not sure if this is a problem. I simply need someone to correct my subs.

    here are my eeread and eewrite subs.

    include "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 500

    CS var PORTB.1 ' Chip select pin
    SCK var PORTB.2 ' Clock pin
    SI var PORTC.6 ' Data in pin
    SO var PORTC.7 ' Data out pin

    B0 var byte '<------- data to be written
    addr var BYTE '<------ eeprom memory location 1,2,3

    d var byte
    t var byte
    ed var byte

    ADCON1=7 ' set all analog pins to digital
    TRISA=%011000 'PORT A
    TRISB=%11110001 'PORT B
    TRISC=%10100000 'PORT C




    eeread:

    for addr = 1 to 3 'eeprom address


    CS = 1
    Shiftout SI, SCK, MSBFIRST, [%110\3, addr\6]
    Shiftin SO, SCK, MSBPOST, [B0]
    CS=0


    if addr = 1 then
    d = B0
    endif

    if addr = 2 then
    t = B0
    endif

    if addr = 3 then
    ED = B0
    endif

    pause 10
    next addr
    return







    ewrite:
    for addr = 1 to 3

    if addr = 1 then
    B0 = D
    endif

    if addr = 2 then
    B0 = T
    endif

    if addr = 3 then
    B0 = ED
    endif

    CS = 1 ' Enable serial EEPROM
    Shiftout SI, SCK, MSBFIRST, [%10011\5, 0\7] ' Send write enable command
    CS = 0

    PAUSE 10

    CS = 1 ' Enable
    Shiftout SI, SCK, MSBFIRST, [%101\3, addr\6, B0] ' Send address and data
    CS = 0
    pause 10
    next addr
    Return



    the ports that the CLK and CS are connected to (portb.1 and portb.2) have programmable weak internal resistors if necesary (Option_reg.7) BUT SI and SO dont. they are on port C.6 and c.7
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    As i remind some PM Darkman solved his problem and much more.
    FIRTS of all add
    Code:
    LOW CS 
    pause 50
    before your main loop.
    those are working. Just change your Shiftin/Shiftout statements
    Code:
    eeread:                                                                                                                                          
            CS = 1                          ' Enable serial EEPROM                                                                                   
            Shiftout DI, CLK, MSBFIRST, [%110\3, addr\6]               
            Shiftin DO, CLK, MSBPOST, [B0]  ' Read data                                                                                           
            CS = 0                          ' Disable                                                                                                
                                               
    
    ' Subroutine to write data at addr in serial EEPROM                                                              
    eewrite:                                                                                                         
             CS = 1                       ' Enable serial EEPROM                                                     
            Shiftout DI, CLK, MSBFIRST, [%10011, 0\4]     ' Send write enable command and dummy clocks               
            pause 10                                                                                                 
            CS = 0                          ' Disable                                                                
                                                                                                                     
            CS = 1                         ' Enable serial EEPROM                                                    
            Shiftout DI, CLK, MSBFIRST, [%101\3 ,addr\6,B0]                                                       
            pause 10                                                                                                 
            CS = 0                          ' Disable
    You don't need any resistor
    Last edited by mister_e; - 13th June 2005 at 04:34.
    Steve

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

  3. #3
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default thanks for reply

    yo dude, thanks alot for the reply. ill try it out tommorow, 2.40 am right now. and let ya know if it worked for me. i have been bashing my brain trying to understand how to use the instructions.

  4. #4
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default It Works!

    the code you gave me works with just a minor tweak. i had to make the eeproms address (addr) increment by 2. so i used addr= 0, addr=2, addr=4,...etc..

    heres the working code. refer to my 1st post for the port settings,variables, n stuff.


    eeread:

    for addr = 0 to 5 step 2 'eeprom address 0

    'read from eeprom
    CS = 1
    Shiftout SI, SCK, MSBFIRST, [%110\3, addr\6]
    Shiftin SO, SCK, MSBPOST, [B0]
    cs=0 ' Disable


    if addr = 0 then
    d = B0
    endif

    if addr = 2 then
    t = B0
    endif

    if addr = 4 then
    ED = B0
    endif

    pause 10
    next addr
    return







    eewrite:
    for addr = 0 to 5 step 2

    if addr = 0 then
    B0 = D
    endif

    if addr = 2 then
    B0 = T
    endif

    if addr = 4 then
    B0 = ED
    endif

    CS = 1 ' Enable serial EEPROM
    Shiftout SI, SCK, MSBFIRST, [%10011, 0\4] ' Send write enable command
    CS = 0

    pause 10

    CS = 1 ' Enable
    Shiftout SI, SCK, MSBFIRST, [%101\3, addr\6, B0] ' Send address and data
    CS = 0
    pause 10
    next addr
    Return

    end



    thank you SO much!!!

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