Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts

Thursday, February 20, 2014

eBible on Cortex M0 with mbed

The eBible code has been ported from to use a Cortex M0 device and external flash chip.  The original chip used an M3 with lots of flash and SRAM, but this M0 part (NXP LPC1114FN28) has only 32Kbytes flash and 4Kbytes SRAM.

The challenge was to reduce and rewrite the functionality using less resources.  The M3 solution had used an SD card with FAT filesystem and had access to 512Kbytes flash and 64Kbytes SRAM.  All that was originally required was the bible.txt file on the SD, and the firmware would index all the books, chapters, and verses for navigation into multiple files on the SD card the first time it ran.  The M3 had no problem loading large sections of the text into memory to parse it into verses.  The M0 with its limited resources has less capability.

The M0 version does not use a file system, so the Bible text and index data are stored sequentially in flash storage (Spansion S25FL164K).  The index data structure is a sequence of structures for books, then intermixed with structures for chapters and verses.  The structures include text offsets, counts, and variable sized arrays pointing to other structures.  A fixed offset to the index structure, and bookmark structure is included in the code.  A separate firmware program for the M3 was written to convert the SD text and indexes and store them in flash.  This program was run once on the M3 to populate the flash chip, then the flash chip was moved to the M0 circuit.

Two different SPI circuits are present with one for the display and one for the flash.  The M0 chip used only has one SPI peripheral, so software SPI (bit banged) was implemented (ported from my C# implementation) to simulate another SPI peripheral.

A Text LCD wrapper library targeting Nokia 5110 was written to reduce the number of changes to the eBible source in porting from a text only lcd to the graphical Nokia 5110 lcd.

The remaining portions of the circuit to mention are the 3.3V voltage regulator (Microchip MCP1702), Nokia 5110 LCD display (purchased on eBay from a seller in Shenzhen, China), two switches, three blue LEDs, three AAA batteries, a battery holder, and some sockets.  A surface mount prototyping adapter board (SO8-50-EB) was used to attach the flash memory.  Two screws secure the battery holder to the circuit board.  The outside LEDs mirror the button presses, and the center LED flashes when bookmarks are changed when holding down both buttons.  Pressing the left button goes back one screen of text, and the right button advances to the next screen of text or next verse whichever comes first.  Holding down the buttons for a time navigates back or forward by multiple verses, chapters, or books depending on how long they are held down.  While navigating large sections of text, the book name, chapter number, and verse number are displayed, then switch back to the text after the buttons are released.

The parts chosen were primarily with consideration of cost.  The memory, display, and microcontroller are mbed online compiler and mbed library.  For debugging, the code was simply exported from the online compiler to Keil uVision 4 using a SeeedStudio Arch to act as the CMSIS-DAP debugger and programmer.  Being able to use a full-featured IDE including debugger for an mbed target is greatly appreciated.  Most of the work was done with the components in a breadboard, then transferred to a solder prototyping breadboard.  The result is a handheld electronic Bible that is smaller and more cost efficient that the originally developed version.
Schematic

Thursday, April 12, 2012

In-between Shield for mbed with 128Mbit Flash


In-between Flash Shield with SST25VF064C
The "In-between Shield" has been developed as a means to extend the attached peripherals of the mbed in a clean looking manner, inspired by the expandability of Arduino, but unique and true to the mbed experience.
This shield is designed to fit and work with the workshop board for mbed.  This is a a breakout board for Ethernet, USB, and SD for mbed.  Instead of the mbed placed in the workshop board, the in-between shield is placed first, and the mbed sits on the shield.  It should be possible to stack additional shields depending on the height of the components on each shield.

The shield itself is composed of a solder breadboard cut to the dimensions of the workshop board, with an additional cutout to avoid the height of the Ethernet jack.  I reduced this board's dimensions further so the USB ports can be visible from above.  This visibility helps with attaching cables and devices.


workshop board
In-between shield
underside
Flash breakout boards


Above board shield in use
The first in-between shield has two 8-pin sockets to accommodate a 16-pin SOIC breakout board with a flash chip attached (SST25VF064C or MX25L12835E).  The flash breakout board can be easily changed out to attach different flash parts. Wiring beneath the shield connects the necessary pins back to the mbed.  The mbed sits in two 2x20 wire wrapping sockets.  No wire wrapping is used in this project.  The advantage to the wire wrapping sockets is the extended leads so the shield sits above the workshop board.

The dual row sockets are used to extend the purpose of the workshop board: each side of the mbed sits in one row, and another row is provided for allowing jumper wires or a single above board shield. The rows of pins are not connected with the shield, it depends on their connections in the workshop board. If the workshop board is not available, a good substitute is another solder breadboard with two 2x20 sockets (short leads), with solder bridges between the pins. 
Solder bridges










The evolution of the flash shield included an ugly do it yourself SOIC to 2x4 pins breakout board made up from two separate 50 mils pitch boards, one for each side of the SOIC chip. An additional board was made to adapt dual 2x4 sockets to a single row 8-pin breadboard friendly connector, with LED to show power. The next iteration was an above mbed board using long single row headers that can be soldered to the bottom of a solder breadboard. Last but not least, the in-between shield was created.

First prototype and breakouts
Above board shield prototype

Source code for this project is posted here. Driver for SST 64Mbit flash (8Mbyte) model 25VF064C including higher level methods for rewrite and buffered read/write to help optimize I/O. Can also work with other 25 series flash and eeprom devices, requiring minor revisions for their capabilities.

The end result of the in-between shield is a clean looking prototype of an mbed connected to a SOIC flash chip that can be further expanded.

Shield shown with MX25L12835E 128Mb Flash