MCP2221 with EEPROM/F-RAM - Page 1
Forum section: electronics / projects

author: daleykd
author_rank: Newbie
timestamp: November 03, 2016, 03:59:44 pm
content: Here's the scenario:I'm designing a DIY kit that's based around an Arduino. Most of the work is done! However, due to design constraints, I am unable to make the Arduino Nano v3's mini-USB easily accessible for the exterior of the enclosure. The users of this kit will need an easy way to access some form of memory in the device. (Originally, it was going to be an SD card. However, the more I investigate, the more I like the idea of an FRAM module.)So, down the rabbit hole I went. What is an easy way for some PC/Mac/Linux app I write to communicate with the FRAM? I think the answer is the MCP2221. It seems to allow USB to I2C. First question: am I right?After the user uses my computer software to write to the FRAM, they would disconnect the USB and then power on the device with 9V external. The Arduino would then read from the FRAM.Second bullet point: it doesn't have to be I2C. I think SPI is an option for these FRAM chips.I saw benSTmax was having great success with this IC. Does anyone know if the I2C portion of it works nicely with Mac/Linux? Any simple tutorials on how to set this IC up?Honestly, I'm not even sure what question to specifically be asking. Any guidance, pointing me in the right direction, is appreciated.Thanks in advance,Kyle

author: senso
author_rank: Frequent Contributor
timestamp: November 03, 2016, 05:47:13 pm
content: You cant use the USB port, so you add another USB port and another chip?Strange..And if you have a custom case, and a board, just put the atmega in your pcb and dont relly on stacking 20 breakout boards.

author: daleykd
author_rank: Newbie
timestamp: November 03, 2016, 06:14:08 pm
content: senso,I get your point, I absolutely do. But this is a cost/benefit for me. I can get an Arduino Nano v3 for $2.50 on eBay. I can't even get an ATMega328P for that. Plus, this is a DIY kit. DIYers in my community hate SMD.Plus, if I use something like the MCP2221, I don't have to write code in my Arduino sketch to handle the interaction between my computer program and the EEPROM/F-RAM. Right?

author: JPortici
author_rank: Super Contributor
timestamp: November 03, 2016, 06:56:48 pm
content: Quotetell them to shut up and stop being lazy. you can't solder a soic / 1206 only if you don't have hands

author: daleykd
author_rank: Newbie
timestamp: November 03, 2016, 07:06:15 pm
content: Quote from: JPortici on November 03, 2016, 06:56:48 pmHAH! As much as I would love to do that, it wouldn't work well for me making a little money. Any response to my actual question regarding the MCP2221?

author: daleykd
author_rank: Newbie
timestamp: November 04, 2016, 10:07:45 pm
content: Am I off base here?

author: Buriedcode
author_rank: Super Contributor
timestamp: November 06, 2016, 01:02:41 am
content: If I understand you correctly you have a kit, that contains an Arduino nano, so FRAM, or other I2C memory, and you want USB communication. You want to use the MCP2221 as a USB->I2C bridge, that the PC side see's as an HID device, and I assume you're writing your own host app and using microchips API.The trouble here is, you'll have two masters on the I2C bus. The Arduino, and the MCP2221, which only implements bus master. Sure, only one will read/write to the memory at any given time, but thats not the point, the MCP2221 will be powered up when the Arduino is powered up, even when no USB is connected, and you'll have two masters.Simplest I can think of is use a USB-serial bridge, connected to the Arduino. That way the Arduino (tired of typing that word now) is the I2C master, and simply receives commands form serial/USB, and reads/writes to the memory and sends data back. It doesn't have to be the FT232, Microchip also do a USB-serial bridge. This has the advantage that because data goes 'through' the micro, you can implement a simple protocol - you have some intelligence there to use to make it easier for the host software to read/write to memory. Many have implemented such simple protocols: a command byte, number of bytes to read/write, a read/write bit, and the data. Maybe even CRC but probably overkill.OR.. use an Arduino Pro micro, which has native USB that defaults as a CDC class (serial port) but can be used in HID. Last time I checked they were about £5.50. There are slight differences from the other '328-based ones, but for the most part its all for the better.A USB-I2C bridge is really only for hooking up I2C slaves to a PC and letting that handle it. If there is a micro-involved, then that can be your USB-I2C bridge, that is after all, all the MCP2221 is - a PIC16F1454 with permanent firmware.

author: mariush
author_rank: Super Contributor
timestamp: November 06, 2016, 02:00:42 am
content: Maybe you could add a jumper or a switch or even a button that when pressed while you power on your device, your microcontroller switches the usb to mass storage (showing one fat16 partition with a single file the size of your fram device, or something like that) instead of serial communication (or whatever you use usb for).Shouldn't be that difficult to implement and the extra code shouldn't be that much in size.

author: daleykd
author_rank: Newbie
timestamp: November 06, 2016, 03:05:04 am
content: Quote from: Buriedcode on November 06, 2016, 01:02:41 amYou understand perfectly.Quote from: Buriedcode on November 06, 2016, 01:02:41 amI didn't even think of that. Thanks. In my head, I wasn't going to power up the Arduino, but I can see why that would happen. I had hoped the USB 5V would power the MCP2221 and the FRAM.Quote from: Buriedcode on November 06, 2016, 01:02:41 amThe Nano has a FT232 or (in my case) a CH340 already on the board, right? I had hoped to not double-up on that, but in essence, I suspect that's what I'm doing.I think what I'll end up doing, though a shoddy solution, is include a USB mini-B male pigtail that plugs into the Nano, then the 4 wires of the pigtail will be soldered right next to a USB standard-A (think printer) female that sticks out of the enclosure. In essence, I created a converter/extender. Then I'll write my sketch/computer program to do as you said regarding the serial communication to the FRAM.Quote from: Buriedcode on November 06, 2016, 01:02:41 amI just hooked up my Pro Micro and see that it shows up as an Arduino Leonardo. I don't know enough of CDC vs. HID. What does HID buy me?Quote from: Buriedcode on November 06, 2016, 01:02:41 amI actuallydidknow that last part.Quote from: mariush on November 06, 2016, 02:00:42 amDUDE!? How the hell can I do that?! That would make my entire situation ideal.EDIT: Thanks, guys, for giving me info I didn't have before. I'm just now learning all of this stuff, and while there's a lot of info on the internet, this topic has stumped me, and I can't seem to find a guide (person or page). There's no one else in my life that even knows a little about any of this.

author: mariush
author_rank: Super Contributor
timestamp: November 06, 2016, 04:09:55 am
content: QuoteHave a look at Microchip's application notes. There's several about USB and mass storage device and there's even a project where the micro acts as mass storage device allowing users to read or write data to a SD card which shows up on computer as removable drive.This should be a good start: AN1003 USB Mass Storage Device Using a PIC® MCUhttp://www.t-es-t.hu/download/microchip/an1003a.pdfThere's also AN1142 - USB Mass Storage Class on an Embedded Host :http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en534220See also : AN1045 - File I/O Functions Using Microchip's Memory Disk Drive File System Libraryhttp://www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en532040App notes for Microchip devices here :http://www.microchip.com/wwwcategory/TaxonomySearch.aspx?show=Application%20Notes&ShowField=no#(go down to USB or Peripheral/USB)