Hello All,
I have been having good momentum in the past few weeks. I was able to get the FRAM I2C to work. You can see the example code below:
/********************************************
writeSample
- Writes one 16 bit (two byte) sample to FRAM
- Uses FRAM automatic incrementing
- Assumes that A1 and A0 lines are set to logic zero
********************************************/
void writeSample(uint32 addr, uint16 sample)
{
uint8 slaveAddr = 0x50;
uint8 pageBit = 0;
uint8 msb = 0;
uint8 lsb = 0;
//Step 1: Break address into components, set the slave address
pageBit = HI16(addr) & 1U;
msb = HI8(LO16(addr));
lsb = LO8(LO16(addr));
slaveAddr |= pageBit;
//Step 2: Write the slave address/page bit & address MSB/LSB to FRAM
I2C_I2CMasterSendStart(slaveAddr, 0);
I2C_I2CMasterWriteByte(msb);
I2C_I2CMasterWriteByte(lsb);
//Step 3: Write the MSB then LSB of the sample to FRAM
I2C_I2CMasterWriteByte(HI8(sample));
I2C_I2CMasterWriteByte(LO8(sample));
I2C_I2CMasterSendStop();
}
I recently hit a stumbling block though. The amount of data transferred off of the FRAM is so large that my computer has difficulty processing all of the USB-UART data! I've been hoping to get around this by using a Python script with PySerial:
import sys
import csv
import serial
#Setup serial port
ser = serial.Serial(port='COM22', baudrate=115200, timeout=60)
#Read
myData = ser.readline()
ser.close()
So far, this has kind of been working. I will need to determine how I can get around this stumbling block. I hope to have a more interesting blog post next time with some sleep data.