accessing fram memory


Closed Thread
Results 1 to 9 of 9
  1. #1
    servo260's Avatar
    servo260 Guest

    Default accessing fram memory

    Hi, I have a FM24C04A (fram memory from ramtron), and I want to access it usin a 16f627. Here is the code I wrote to do some tests (it's part of a bigger code).
    What I want to do is to write a 5 (decimal) in some adress and then read it and write it to a variable, then send the variable to a display.
    I was experimenting with shiftout and shiftin, but I don't really know what I am doing.
    The memory uses the same pin to read and write, I tried to use also only one pin on the pic, Is it possible?




    @ DEVICE INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF, BOD_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF
    include "modedefs.bas"
    define osc 4

    TRISA = %00000000
    TRISB = %01000110

    intcon = 0


    clear

    num var byte
    x var word
    cuenta var byte
    velocidad var word
    circunferencia var byte
    demora var byte

    t1 var portb.4
    t2 var portb.5
    t3 var portb.3
    sda var porta.7
    scl var porta.6

    timer con 9

    OPTION_REG = %10000111
    INTCON = %11100000
    CMCON = 7

    shiftout sda, scl, 5, [%10100000, %00000000, 5]
    shiftout sda, scl, 5, [%10100000, %00000000, %10100001]
    TRISA.7 = 1
    shiftin sda, scl, 7, [circunferencia]
    TRISA.7 = 0

    x = circunferencia

    display:
    num = x dig 0 ; unidad de X y lo manda a num
    porta = num
    high t1
    pause 3
    low t1
    num = x dig 1 ; decena de X y lo manda a num
    porta = num
    high t2
    pause 3
    low t2
    num = x dig 2 ; centena de X y lo manda a num
    porta = num
    high t3
    pause 3
    low t3
    goto display

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


    Did you find this post helpful? Yes | No

    Default

    As i know those 24c04 are I2C device... you must use I2CREAD and I2CWRITE
    Steve

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

  3. #3
    servo260's Avatar
    servo260 Guest


    Did you find this post helpful? Yes | No

    Default

    Can you give me a code example? I never use memories before.
    What I don't understand is the "control" in the i2cwrite command.

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


    Did you find this post helpful? Yes | No

    Default

    Have a look to the PBP manual.

    Have a look to this code from Melabs website

    and much on this forum.. search for I2CREAD and I2CWRITE
    Steve

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

  5. #5
    servo260's Avatar
    servo260 Guest


    Did you find this post helpful? Yes | No

    Default

    this is what I have done, I changed this

    shiftout sda, scl, 5, [%10100000, %00000000, 5]
    shiftout sda, scl, 5, [%10100000, %00000000, %10100001]
    TRISA.7 = 1
    shiftin sda, scl, 7, [circunferencia]
    TRISA.7 = 0

    to this

    i2cwrite sda, scl, %10100000, %0000000000, [%00000101]
    i2cread sda, scl, %10100001, %000000000, [circunferencia]

    But the display shows 128 and not 005

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


    Did you find this post helpful? Yes | No

    Default

    your adress must be 8 bits long.. not much. And you don't need to change you control word... PBP will do it for you.

    also refer to your datasheet about the Twrite delay. some will need few milliseconds before the write cycle is finish.

    so try
    Code:
    i2cwrite sda, scl, %10100000, 0, [5]
    pause 10 ' safe delay
    i2cread sda, scl, %10100000, 0, [circunferencia]
    Last edited by mister_e; - 8th March 2005 at 06:42.
    Steve

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

  7. #7
    servo260's Avatar
    servo260 Guest


    Did you find this post helpful? Yes | No

    Default

    I read at the ramtron page that this memory uses a SPI protocol. Is It the same as I2C?

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


    Did you find this post helpful? Yes | No

    Default

    i'm actually read the datasheet

    it's really I2C or some will call that 2-wire

    SPI or Microwire is for 93c serie, some Xicor (the old X2444, S-29220 and many others). Those you need 4 i/o
    CS
    CLK
    SDI
    SDO

    and those are use with SHIFTIN/SHIFTOUT.

    Those Ramtron FRAM are great... they say that you don't need any delay between the write and the read... they run at the same speed than the bus. Great!
    Steve

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

  9. #9
    servo260's Avatar
    servo260 Guest


    Did you find this post helpful? Yes | No

    Default

    Hi, thanks a lot fot the info. I put the wrong values for the resistors. Everithing is working fine now.

Similar Threads

  1. Fram Memory
    By MARGARITA in forum Serial
    Replies: 5
    Last Post: - 1st October 2008, 13:30
  2. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  3. Replies: 4
    Last Post: - 2nd March 2007, 06:12
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 02:37
  5. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38

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