Paragon Innovations Blog Banner

A Picture is Worth…

by Mike Wilkinson on July 8, 2011

A Picture is Worth a Thousand Words Hours of Debug Time.

~Michael Edgar~

I got trapped in an interesting dilemma this week.  I was having trouble making a TI MSP430 talk to a serial port device over the SPI bus.

SPI (Serial Peripheral Interface) bus is a 4 wire method of connecting external peripheral devices (memories, I/O, time of day, etc.) to a microcontroller.  The bus definition was created by Motorola (now Freescale) and has become a de facto industry standard.

Therein lays the rub.

De facto standards are not controlled or policed.  The problem I eventually discovered is that the text description in the TI datasheet is difficult to decipher and the bus modes were numbered differently by TI than by Motorola (and most of the known universe).

The SPI mode is set by two variables, the first determines when the data is clocked out and read, and the second determines if data is read on the first clock.  The table below shows what I discovered after reviewing the TI timing diagram.  (FR means data is clocked out on a falling edge and in on a rising edge, RF means data is clocked out on a rising edge and clocked in on the falling edge.)

We eventually found and fixed the problem by comparing the timing diagrams of the peripheral to the timing diagrams in the TI datasheet.

The obvious question is, how do we do it right the first time and avoid the debugging in the future?  Well there are a couple of answers.  Our senior engineers will tell you that they have had enough problems with SPI Mode that they usually ignore the prose and look at the diagrams to figure out what they need to do.  The other answer and more general lesson learned, is that we were dealing with a “standard” interface, but TI chose a completely different set of names for the signals and control bits (see the table below).

The moral to our story, when dealing with any interface it is always a good idea to look at the timing diagrams, especially when the parts being interfaced use different naming conventions.


TI MSP430x4xx Family User’s Guide, Table 18-9: USART SPI Timing

NXP SC16IS741 Product Data Sheet, Fig. 20: SPI operation


Leave a Comment

Previous post:

Next post: