Arduino and Cypress SPI FM25CL64B FRAM

lightning
The FM25CL64B is a 64K-bit ferroelectric RAM (F-RAM or FRAM) memory chip. Unlike typical flash and EEPROM memory, FRAM is capable of performing write operations at bus speed. According to the Cypress datasheet, this FRAM chip is capable of being clocked at up to 40MHz. I purchased a few SOIC-8 (150mils) chips for testing. I soldered the chip to a dipmicro SMT SOIC-to-DIP adapter PCB and kludged together a simple test program for my arduino:

FM25CL64Ba

FM25CL64Bb

Since the chip is not 5V tolerant, I used a SparkFun 12009 level shifter to perform the 5V to 3V3 logic conversions. Here is how I connect the arduino, FM25CL64B and level shifter:

Arduino--Logic Conv--FRAM
D13------TXH/TXL-----6.SCK
D12------------------2.MISO
D11------TXH/TXL-----5.MOSI
D10------------------1.CS
3V3------LV
5V-------HV
GND------HV GND
GND------------------4.VSS
3V3------------------8.VCC
3V3------------------7.HOLD (tie to Vcc if not used)
3V3------[10KR]------1.CS
                     3.WP (active low, tie to Vcc if not used)

Arduino program:

//
//FM24CL64B SPI F-RAM
//64-Kbit simple test
//
#include <SPI.h>

//SRAM opcodes
#define WREN  0b00000110 //set write enable latch
#define WRDI  0b00000100 //write disable
#define RDSR  0b00000101 //read status register
#define WRSR  0b00000001 //write status register
#define READ  0b00000011 //read memory data
#define WRITE 0b00000010 //write memory data
 
uint8_t SpiRAMRead8(uint16_t address) {
  uint8_t read_byte;
 
  PORTB &= ~(1<<PORTB2);              //set CS low
  SPI.transfer(READ);
  //13-bit address MSB, LSB
  SPI.transfer((char)((address>>8)&0xff));
  SPI.transfer((char)address);
  read_byte = SPI.transfer(0xFF);
  PORTB |= (1<<PORTB2);               //set CS high
  return read_byte;
}
 
void SpiRAMWrite8(uint16_t address, uint8_t data_byte) {
  PORTB &= ~(1<<PORTB2);              //set CS low
  SPI.transfer(WREN);
  PORTB |= (1<<PORTB2);               //set CS high
  PORTB &= ~(1<<PORTB2);              //set CS low
  SPI.transfer(WRITE);
  //13-bit address MSB, LSB
  SPI.transfer((char)((address>>8)&0xff));
  SPI.transfer((char)address);
  SPI.transfer(data_byte);
  PORTB |= (1<<PORTB2);               //set CS high
}
 
void setup(void) {
  uint16_t addr;
  uint8_t i;

  Serial.begin(9600);
  pinMode(10, OUTPUT);                //CS
  pinMode(11, OUTPUT);                //MOSI 
  pinMode(12, INPUT);                 //MISO
  pinMode(13, OUTPUT);                //SCK
  PORTB |= (1<<PORTB2);               //set CS high
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider (SPI_CLOCK_DIV2);
  for (addr=0; addr<32; addr++) {
    SpiRAMWrite8(addr, (uint8_t)addr);
    Serial.print("Addr: ");
    Serial.print(addr);
    i = SpiRAMRead8(addr);
    Serial.print(" | Read: ");
    Serial.println((uint16_t)i);
  }
}
 
void loop() { }

Advertisements

About Jim Eli

µC experimenter
This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s