Help debuging FRAM SPI breakout

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Yasen6275
 
Posts: 10
Joined: Sun Nov 20, 2022 4:44 am

Re: Help debuging FRAM SPI breakout

Post by Yasen6275 »

I have the feeling you are assuming that I know something I don't really know. Or my poor understanding of English is failing me again. Might be both.
mikeysklar wrote: Wed Nov 30, 2022 9:36 pm You had not mentioned the value you were seeing 8k addresses.
Me bad. I should have told that the code I have shown was giving me 8192 bytes 8.0 KB as outout.
mikeysklar wrote: Wed Nov 30, 2022 9:36 pmThere is a different address size on the FRAM devices. The 4Mb is a 4-byte address size (32-bit or double word).
So far so good. That are thing that assumed when purchasing the board.
mikeysklar wrote: Wed Nov 30, 2022 9:36 pm It uses fram.begin(3) in the Arduino section of the guide.
That's one of the reasons to use python. I hoped that python lib will do that automatically.
mikeysklar wrote: Wed Nov 30, 2022 9:36 pm I realize how obscure that is when you are using CircuitPython. The smaller FRAM devices use the default 2-byte, single word address sizing.
Here you've lost me.
I have read these. Are you implying that full size is usable only in C/Arduino. That's not great but not terrible either.
mikeysklar wrote: Wed Nov 30, 2022 9:36 pm
You can try using this to determine fram size and work in a usable address space. I would expect your unit to show 125k usable addresses (32-bit per address).

Code: Select all

import board
import busio
import digitalio
import adafruit_fram

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D7)
fram = adafruit_fram.FRAM_SPI(spi, cs)

# size returned by len()
len(fram)

# can be used with range
for i in range(0, len(fram))
I'm totally lost here

//Edit
Are you teling me that fram is a list of 8192 bytearrays with size of 512?

//Nope

Code: Select all

print("fram",len(fram))
print("fram[0]", len(fram[0]))

Code: Select all

fram 8192
fram[0] 1

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Help debuging FRAM SPI breakout

Post by mikeysklar »

I see the issue.

There is no auto detect being used with the CircuitPython code from the FRAM SPI devices. It defaults to the smallest 8KB device so that is why you are maxing out there. So initializing with max_size set should resolve it.

Code: Select all

fram = adafruit_fram.FRAM_SPI(524288, spi, cs)
Try this:

Code: Select all

import board
import busio
import digitalio
import adafruit_fram

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D7)
fram = adafruit_fram.FRAM_SPI(524288, spi, cs)

# size returned by len()
len(fram)

print("fram",len(fram))
print("fram[0]", len(fram[0]))

based on the docs:

https://docs.circuitpython.org/projects ... _fram.FRAM

User avatar
Yasen6275
 
Posts: 10
Joined: Sun Nov 20, 2022 4:44 am

Re: Help debuging FRAM SPI breakout

Post by Yasen6275 »

Thanks for your time, help and links.

Just for the record the correct way to define size is:

Code: Select all

fram = adafruit_fram.FRAM_SPI(spi, cs, max_size = 524288)
May I kindly suggest that info to be present here. I think that will be very helpful.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Help debuging FRAM SPI breakout

Post by mikeysklar »

Thank you for the correction on syntax.

The guide has been updated.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”