9.1_title.png

 

In the last chapter, we were able to get the MCU to talk to the outside world, so now we can monitor the embedded application from an external computer.  Awesome.  But unless you plan to bolt a computer to your embedded gadget, that isn’t going to help you create your super-compact, battery-powered, embedded widget.  One of the main benefits of building an embedded gadget is the ability for it to employ a multitude of intelligent components in a self-contained manner, without the help of a connected computer.

 

Your MCU knows how to speak the language of Serial Peripheral Interface (SPI), which is one of the key communication conduits for embedded gadgets.  With this skill, you will be able to expand your MCU into a full-featured device chock full of amazing sensors, adapters, drivers, actuators, and more.  

 

In this chapter, we will learn how to connect the EFM32 MCU to a flash memory chip via the SPI bus.  This capability gives you the power to store gigabytes of information, either permanently or temporarily installed in your device.  But more importantly, the SPI bus standard gives you the capability to communicate with all of those interesting devices we just talked about.  We will also learn about how to read component specifications so that you will know how to order your parts when the time comes, and then build up those bare components into a breakout board for prototyping purposes.

 

This chapter also introduces the concept of multitasking, since we will be reading data from the serial port and then programming that data to the flash chip, one “page” at a time.  This requires that we build a ring buffer, a type of buffer that can be used to hold data that is in transit from one place to another without overwriting data that has not yet been written to the destination device.

 

The SPI device used in this lesson is a soldered-down SPI flash.  These chips are very common in embedded design and available from many manufacturers with a very similar spec.  If you wish to offer removable storage for your gadget, you can include a SD card or microSD card slot.  These cards, popular in cameras, are available to the consumer and are small enough to fit in the smallest of gadgets.  There are libraries available for the EFM32 that will allow these cards to be used with the FAT filesystem.  See Application Note AN0030 FAT on an SD Card for more details.  The SD card devices can also be configured work in SPI mode, however, if programmed in SPI mode, the cards will not be readable on a personal computer.

 

Materials Needed for This Lesson

  • Schmartboard breakout board -- 0.050” (1.27mm) pitch
  • Spansion 8Mbit SPI flash chip S25FL208K0RMFI011
  • Hook up wire
  • Computer with a USB-to-serial port adapter and terminal emulator software

Serial Peripheral Interface (SPI) Flash Device Hardware Connections

To get started, you will need a SPI device for the experiment.  One option is to buy a pre-built SPI flash breakout board and solder header pins onto the breakout board, then wire that to the Starter Kit.  I could not find a reliable source for such a breakout board, but you are welcome to try to find one if you would like to avoid the soldering contained in this lesson.  Regardless, this chapter will teach you how to build your own breakout board.  You will probably need to do that at some point down the road, so this is good (and cheap) practice to get these skills under your belt. 

 

Building the SPI Flash Breakout Board

Before you can purchase your SPI flash chip and Schmartboard breakout, you must figure out how to buy the right board for your test chip by examining the pinout and mechanical drawing of the chip.  It can sometimes be a puzzling chore to make sense of the mechanical drawings. The engineers who create these drawings certainly know all kinds of strange acronyms and symbols that most people have probably never seen before. The tech writers seemingly drop the drawings into the spec with no introduction or further explanation at all, leaving you to decipher the hieroglyphs.  I’ll do the best I can to decipher the important parts of the Spansion SPI flash chip.

 

Sections 10.1 and 10.2 of the Spansion flash memory spec show two different packages for this part.  A package is the plastic part of the chip that houses the electrical contacts.  The actual silicon wafer with all of the brains is encased inside of the package. In this case, one package looks squarer than the other, and one is 150-mil (more about mils in a moment) and one is 208-mil.  So they must be different, right?  I have no idea what SOA versus SOC means.  Sometimes there are pages and pages of these drawings as some chips are available in three, four, or five packages.  But sometimes the different drawings simply detail different aspects of the same package footprint, such as the copper landing pads, the solder paste or the solder mask, and thermal soldering information.  You have to wade through all of that figure out what it is trying to tell you, even though things like SOA and SOC are never defined anywhere.  In this case, I am reasonably sure that there are in fact two packages available, as detailed by the two drawings.

 9.1_pitch.png

So which package should we get?  Well, we would like to work on a part that has the largest pin pitch, which is the center-to-center distance between any two adjacent pins.  This will make soldering and reworks easier for our prototyping needs.  When we look at the drawings, we see that the distance between two pins is marked with an ‘e’ so I look at the table beneath the part drawing and we find ‘e’ in the table.


We see that ‘e’ for the pin pitch is the same on both parts of 0.050 inches or 1.27mm, so either chip will do.  Since we are prototyping, we will pick the larger of the two packages.  When you go to build your own boards, it might make more sense to pick the smallest package possible.  But for now we will pick the larger one, the 208-mil package. 

9.1_package_sizes.png

 

By the way, a mil is sort of PCB designer slang for a milli-inch.  This is so confusing, but a mil just means .001 inches, and 208-mils is 0.208 inches.  A mil has nothing to do with millimeters.  The BSC stands for “Basic Spacing between Centers.”  I know that only because I Googled it.  If you really want to get a headache, read all of the notes next the table.  “Dimension b does not include a dambar protrusion.”  Well that’s a relief.  I’m sure all of this stuff is important to someone but you have to learn how to extract the information that you need from these mind-bogglingly complex documents.

 

Now that we know that we want the 208-mil SOC package, it should be easy to order it from an online parts warehouse, right?  Nope.  In my experience the symbols on the spec sheet regarding the mechanical package are sometime completely different from the equally baffling package descriptions that you will find at the part depots.


In this case of this chip, Spansion has made it easier by encoding the package type in the part number and explaining the part number in the spec.  You have to hunt this down, but at least it was in there.  You won’t always have it so easy.

 

9.1_ordering.png

 

So now we know that we need a S25FL208K0RMFI011, and I can search for that at Digikey or any other part warehouse and be sure that I am going to get the right chip.  When I go lookup this part, I see that is about $0.37 each and I can buy a ten pack for $3.60.  So we should order ten packs of both the 150-mil and the 208-mil parts and the shipping charge will actually cost more than the parts.  I prefer to over-order at this stage and get to know my footprint options.  It is better to learn about this stuff now rather than after we have placed these parts into a custom-built PCB.

 

Now we can finally order our Schmartboard with pin pitch of 1.27mm and at least 8 pins in total.  The Schmartboard already accepts a wide variety of chip diameters so we don’t have to worry about that.  The same Schmartboard will easily accommodate the 150-mil and the 208-mil packages.


Once the breakout boards and chips arrive, we can solder the chips down following the instructions that come with the Schmartboard.  Note that I always add extra solder to the pads on the Schmartboard rather than heat up the solder that is already there as it is described in the instructions.  I find that the extra mound of solder and flux makes it easier to slop on top of the chip leg.

 

9.1_chip_soldering.png

 

In the next section, we will connect the flash chip to the EFM32 and set up the SPI software drivers.

 

PREVIOUS | NEXT

  • Blog Posts
  • Makers