Cypress FRAM

johndk

Senior Member
Hi All,

I'm experimenting with the Cypress FM24CL04B FRAM chip. It's got a lot to offer, especially in speed and low power signature. I thought it was a drop-in replacement for the 24LCxxx and although pin-wise it is, program-wise, there's a difference. It has to do with the i2c read. It was driving me crazy for a while until I read the data sheet about a hundred times. Apparently, one can not do a random read by simply sending the "address to read" as in the hi2cin command. It only reads from the point of the last write. e.g. If you write some bytes to address x, then when you read, you'll start reading at address x (not matter what address you specify in the hi2cin command). As I underestand it, the data sheet states that the way to do a random read is to first to an "empty" write to the desire location (no data) and then issue the read command for the desired number of bytes. That empty write is to place the desired random address in the internal address latch.

So here's my problem. I know there is a manual way to do the hi2cout command. But I can't find it. The editor will not allow an empty Hi2cout ... as in "hi2cout address, ()". Can someone refresh me as to how to accomplish such an empty write command?

John
 

bpowell

Senior Member
It's possible you won't be able to use the PICAXE commands, as they're formatted to expect address and then variable. I looked at the hi2cout command, and it looks like you can send "hi2cout (variable)" just by itself...if you can do that, then you'll want to send the address of your desired empty write in the variable.
 

hippy

Ex-Staff (retired)
The PICAXE I2C implementation is I2C compliant. A write, "HI2cOut adr,(wrData)" performs the following -

Start | <id>+Write | <adr> | <wrData> | Stop

A Read, "HI2cIn adr,(rdData)" -

Start | <id>+Write | <adr> | Repeated Start | <id>+Read | <rdData> | Stop

The HI2CIN provides the address via the write before the read. There are screenshots in the HI2COUT and H2CIN commands in PICAXE Manual 2 which show the waveforms.

The FRAM seems to comply with the I2C spec and the standard protocol which the PICAXE implements so it should be working. If it isn't it is perhaps something else wrong; missing pull-ups, crossed-over signals, wrong Device ID.
 

johndk

Senior Member
Thanks hippy,

I guess I'll have to try again to find the problem. I have a circuit where the 24LC256 works as expected. But when I substitute the Cypress chip, it does not. So I know it's not the circuit. I can write the the Cypress. But I can't do a random read. I only get what I've just written to the chip as described before. I thought I'd found the answer with the i2c commands. But as you describe the action of hi2cin, it exactly complies to the cypress data sheet description.

So back to some more head scratching.

What I really like about this chip is the write speed, essentially zero delay. And, if I've read correctly, you also don't have to worry about a 64 byte internal buffer (i.e. block writes) which allows for much more efficient use of space when storing sequential records. The write speed eliminates the need for a buffer because it's done before you can send the next byte.

John
 

Rick100

Senior Member
Hi John,

You can give this a try. I don't have your FRAM chip so it's just a shot in the dark.

Code:
[color=Blue]SYMBOL [/color][color=Purple]slave_add [/color][color=DarkCyan]= [/color][color=Purple]b0[/color]
[color=Blue]SYMBOL [/color][color=Purple]page_sel [/color][color=DarkCyan]= [/color][color=Purple]bit1[/color]

[color=Blue]SYMBOL [/color][color=Purple]address [/color][color=DarkCyan]= [/color][color=Purple]w1     [/color][color=Green]'location were trying to read or write
   [/color][color=Blue]SYMBOL [/color][color=Purple]add_low [/color][color=DarkCyan]= [/color][color=Purple]b2
   [/color][color=Blue]SYMBOL [/color][color=Purple]add_hi [/color][color=DarkCyan]= [/color][color=Purple]b3[/color]

[color=Blue]SYMBOL [/color][color=Purple]data_in [/color][color=DarkCyan]= [/color][color=Purple]b4


   slave_add [/color][color=DarkCyan]= [/color][color=Navy]%10101100   [/color][color=Green]'bits 7-4 = %1010 for slave ID , bits 3-2 = device select(A2 A1 pins) , bit 1 = page select , bit 0 = R/W (Picaxe firmware handles it)

   [/color][color=Purple]address [/color][color=DarkCyan]= [/color][color=Navy]1

   [/color][color=Blue]if [/color][color=Purple]address [/color][color=DarkCyan]> [/color][color=Navy]255 [/color][color=Blue]then
      [/color][color=Purple]page_sel [/color][color=DarkCyan]= [/color][color=Navy]1
   [/color][color=Blue]else
      [/color][color=Purple]page_sel [/color][color=DarkCyan]= [/color][color=Navy]0
   [/color][color=Blue]endif

   hi2csetup I2CMASTER[/color][color=Black], [/color][color=Purple]slave_add[/color][color=Black], [/color][color=Blue]I2CSLOW[/color][color=Black], [/color][color=Blue]I2CBYTE

   hi2cout([/color][color=Purple]add_low[/color][color=Blue])

   hi2cin([/color][color=Purple]data_in[/color][color=Blue])

   end[/color]
If it doesn't work you might post some of the code you've tried.

Good luck,
Rick
 

johndk

Senior Member
I all,

I've been working out a different bug in my application and had to put FRAM aside for a bit. But now I'm back to trying to make that work. I'm using i2cfast for this connection. In fact, the chip specs say it is capable of speeds up to 1MHz (even faster - be nice if PicAxe basic could add i2cfastM or something like that).

I've been using code that worked fine with my 24LC256, just swapping out the chips in hopes that the Cypress was a true "functional clone". It is possible I did something wrong on my breadboard because I have so many balls in the air right now. So back to checking all the wiring and running some code.

Thanks for the suggestion Rick. I'll take a look at that.
 

edmunds

Senior Member
All my senses following this thread as I have planned two of the largest (2Mbit was it?) of those for storing map data in the final design of my self navigating model supercar. They also have a version with unique serial number, which can be used for various security things in commercial application. Marvelous coincidence :).

Best of luck,

Edmunds
 

johndk

Senior Member
Happy Days! It IS a direct drop-in replacement for the 24LCxxx chip after all. I must have had something screwed up in my wiring before. Sometimes its good to get away from something frustrating for a while.

I don't currently have the 2Mb chips, but surely would be interested. I'm using openlog for mass data storage which is somewhat problematic. Mostly, it uses too much power and too much space. My second problem with it is that it doesn't always respond nicely and I have to do too many (machine initiated) resets. And those cursed 3 extra characters (ctrlZ) it throws in at the beginning of each transmission have to be scrubbed afterwards.

So Edmunds, I would be very interested in your project with the 2Mb chips.
 

edmunds

Senior Member
So Edmunds, I would be very interested in your project with the 2Mb chips.
Congratulations!

Sorry @johndk, I stand corrected - this is 1Mbit chip, not 2. But I have found space for two of them on the tiny PCB. And a future expandability of 2 more, which is the limit you can address with i2c. I need to try the one with serial number and I cannot find it available in Europe in normal quantities and reasonable delivery costs. Digikey has them in stock, but, again, shipping a few ICs is just not reasonable. So either I will put together a larger shipment from the US or wait for my cousin (lives in the US) to visit :).


Regards,

Edmunds
 

inglewoodpete

Senior Member
... this is 1Mbit chip, not 2. But I have found space for two of them on the tiny PCB. And a future expandability of 2 more, which is the limit you can address with i2c.
You only need one socket for four of these chips.

If you are skilled at soldering then bend the A1 and A2 legs out slightly on three of the chips. Stack up to four chips on top of each other, soldering 6 legs together (all but A1 and A2). Then, using short lengths of tinned copper wire, solder a pattern of 00, 01, 10 and 11 wiring to the A1 and A2 pins for each chip to the Vss and Vdd pins for logic 0 and 1.

This will give you the maximum of 4Mb or 512MB of FRAM in a single 8-pin DIP socket.
 

johndk

Senior Member
I thought I had it working ... but NO.
With the Cypress chip installed I can read and write all day. BUT only to and from address 0. It seems it ignores any addressing, whether read or write and always uses 0.

If someone comes up with the solution, please post.
 

hippy

Ex-Staff (retired)
It would seem unlikely to be chip failure but it is perhaps possible. If two chips behave the same way I would discount that and assume there is some other problem either in terms of hardware connection or test program. Perhaps post your test code. Does the test code work for normal, non-FRAM, I2C memory ?
 
Top