Fujitsu MB85RCxx I2C FRAM test program

Dependencies:   mbed MB85RCxx_I2C

Connectivity

MB82RCxx pinmbed LPC1114FN28 pinmbed LPC1768 pinArudino form factor
1 (A0)22 (GND)1 (GND)GND
2 (A1)22 (GND)1 (GND)GND
3 (A2)22 (GND)1 (GND)GND
4 (VSS)22 (GND)1 (GND)GND
5 (SDA)2 (dp5)9 (p9)D14
6 (SCL)6 (dp27)10 (p10)D15
7 (WP)22 (GND)1 (GND)GND
8 (VDD)21 (VDD)40 (VOUT)3V3

Note

SDA and SCL must be pulled-up by 2.2k-ohm registers.

Committer:
MACRUM
Date:
Sat Apr 22 12:31:39 2017 +0000
Revision:
3:eb1c38ce9b0b
Parent:
1:e15a9be72b69
Update library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:7e86fd056d40 1 #include "mbed.h"
MACRUM 1:e15a9be72b69 2 #include "MB85RCxx_I2C.h"
MACRUM 0:7e86fd056d40 3
MACRUM 0:7e86fd056d40 4 DigitalOut myled(LED1);
MACRUM 0:7e86fd056d40 5 Serial pc(USBTX, USBRX);
MACRUM 0:7e86fd056d40 6
MACRUM 0:7e86fd056d40 7 #if defined(TARGET_LPC1768)
MACRUM 1:e15a9be72b69 8 MB85RCxx_I2C fram(p9, p10);
MACRUM 0:7e86fd056d40 9 #elif defined(TARGET_LPC1114)
MACRUM 1:e15a9be72b69 10 MB85RCxx_I2C fram(dp5, dp27);
MACRUM 0:7e86fd056d40 11 #else
MACRUM 1:e15a9be72b69 12 MB85RCxx_I2C fram(D14, D15);
MACRUM 0:7e86fd056d40 13 #endif
MACRUM 0:7e86fd056d40 14
MACRUM 0:7e86fd056d40 15 int main() {
MACRUM 0:7e86fd056d40 16 char buf[16];
MACRUM 0:7e86fd056d40 17 uint32_t address;
MACRUM 0:7e86fd056d40 18
MACRUM 0:7e86fd056d40 19 pc.baud(115200);
MACRUM 0:7e86fd056d40 20 pc.printf("\nFujitsu MB85RCxxx FRAM test program\n\n");
MACRUM 0:7e86fd056d40 21
MACRUM 1:e15a9be72b69 22 fram.read_device_id(buf);
MACRUM 0:7e86fd056d40 23
MACRUM 0:7e86fd056d40 24 pc.printf("read device ID = 0x%x 0x%x 0x%x\n\n", buf[0], buf[1], buf[2]);
MACRUM 0:7e86fd056d40 25
MACRUM 1:e15a9be72b69 26 fram.fill(0, 0, 256);
MACRUM 0:7e86fd056d40 27
MACRUM 0:7e86fd056d40 28 for (int i = 0; i < 16; i++) {
MACRUM 0:7e86fd056d40 29 buf[i] = i;
MACRUM 0:7e86fd056d40 30 }
MACRUM 1:e15a9be72b69 31 fram.write(0, buf, 16);
MACRUM 0:7e86fd056d40 32
MACRUM 0:7e86fd056d40 33 for (address = 0; address < 0x80; address += 16) {
MACRUM 1:e15a9be72b69 34 fram.read(address, buf, 16);
MACRUM 0:7e86fd056d40 35 pc.printf("%08X : ", address);
MACRUM 0:7e86fd056d40 36 for (int i = 0; i < 16; i++) {
MACRUM 0:7e86fd056d40 37 pc.printf("%02X ", buf[i]);
MACRUM 0:7e86fd056d40 38 }
MACRUM 0:7e86fd056d40 39 pc.printf("\n");
MACRUM 0:7e86fd056d40 40 }
MACRUM 0:7e86fd056d40 41
MACRUM 0:7e86fd056d40 42 pc.printf("\n");
MACRUM 0:7e86fd056d40 43 for (address = 0; address < 0x100; address++) {
MACRUM 1:e15a9be72b69 44 fram.write(address, (uint8_t)address);
MACRUM 0:7e86fd056d40 45 }
MACRUM 0:7e86fd056d40 46 for (address = 0; address < 0x100; address += 16) {
MACRUM 1:e15a9be72b69 47 fram.read(address, buf, 16);
MACRUM 0:7e86fd056d40 48 pc.printf("%08X : ", address);
MACRUM 0:7e86fd056d40 49 for (int i = 0; i < 16; i++) {
MACRUM 0:7e86fd056d40 50 pc.printf("%02X ", buf[i]);
MACRUM 0:7e86fd056d40 51 }
MACRUM 0:7e86fd056d40 52 pc.printf("\n");
MACRUM 0:7e86fd056d40 53 }
MACRUM 0:7e86fd056d40 54
MACRUM 0:7e86fd056d40 55 while(1) {
MACRUM 0:7e86fd056d40 56 myled = 1;
MACRUM 0:7e86fd056d40 57 wait(0.2);
MACRUM 0:7e86fd056d40 58 myled = 0;
MACRUM 0:7e86fd056d40 59 wait(0.2);
MACRUM 0:7e86fd056d40 60 }
MACRUM 0:7e86fd056d40 61 }