Professional Documents
Culture Documents
Using-SPI-protocol-with MEAS-pressure-sensors-AMSYS-an510
Using-SPI-protocol-with MEAS-pressure-sensors-AMSYS-an510
This application note describes the possibility of communication between a microcontroller and MEAS
Switzerland's pressure sensor modules (MS55XX series) via SPI protocol.
SPI stands for Serial Peripheral Interface. It is frequently used when few I/O lines are available, but
communication between two or more devices must be fast and easy to implement.
SPI is a synchronous protocol that allows a master device to initiate communication with a slave device. It is
implemented in many standard microprocessors (Microchip, Silicon Laboratories, Atmel, ST,…) by a hardware
module.
The great advantage of using this protocol is it simplifies the communication with the sensor module. In fact,
there is no need to generate the serial clock, as it is generated by the microcontroller. You only have to place
data and commands in a buffer and the microcontroller send it. (Same utilization than an USART)
This protocol needs a minimum of three lines between the master and a slave. An additional line must be added
for each slave in multi-slave operations in order to select it.
MASTER
MISO
R/W R/W
SCLK
Control Control
The communication between a master and a slave is always a data transfer. When the master sends
something, it will receive a data at the same time. If the data received is not read, it will be lost at next data
transfer. When the master wants to receive something, it has to send a dummy data to shift the answer placed
in the slave’s shift register. For more details about SPI, refer to microcontroller datasheet.
OSC
OSCin MCL
With:
MISO = Master In & Slave Out
MOSI = Master Out & Slave In
SDO = Serial Data Out
SDI = Serial Data In
SCL or SCKL = Serial Clock
OSC = Oscillator at 32.768 kHz
For ex: SG3030JC
Note:
The oscillator is not necessary for data transmission but for sensor ADC. It can be used as clock for the
microcontroller too.
MOSI or SDO
SCL
Microcontroller
CS1
CS2
CS3 Chip Select MS55XX IC
OE
MS 55XX
sensor
OSC
With:
CS = Chip Select (Or slave select SS)
IC = 3-State buffer (high-Z driver)
For ex: 74HC1G125
OSC = Oscillator at 32.768 kHz
For ex: SG3030JC
Remarks:
- As MEAS Switzerland’s sensor modules haven’t any high-Z driver on DOUT, it is compulsory to add a 3-state
buffer on the line between DOUT and MISO-line of the SPI bus in order to allow communication with the other
slaves.
- The lines MISO, MOSI and SCL have to be connected on the right ports of the microcontroller (See
microcontroller datasheet). The CSx lines can be connected to general digital I/O.
- Most components using SPI have an active-low input (CS\) to select it. Using a 74HC1G125 has the same
meaning because this driver has an Output-Enable active-low input(OE\).
4 SOFTWARE
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
DIN
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Bit11
address word 2
With SPI protocol, it is only possible to send 8 bits at a time (one byte). The frame must be divided by two and
some “0” must be placed before and after the frame to complete the two bytes.
It becomes: 0-0-0-1-1-1-0-1-0-1-1-0-0-0-0-0
Separated in bytes: 0-0-0-1-1-1-0-1¦0-1-1-0-0-0-0-0
In Hexadecimal: 1Dh 60h
Remark:
The 0 added after the frame is placed to have one more clock after the stop bits on the SCLK line. (As shown on
the scope above)
With SPI protocol, two parameters need to be checked or adjusted during the configuration of microcontroller’s
SPI module:
Clock Idle state must be low.
Transmission must occur on rising edge of the serial clock when the microcontroller wants to send data received
by the sensor. On the other side, when the microcontroller wants to receive data sent by the sensor
transmission must occur on the falling edge of the clock.
Send Receive
Receive Send
REVISION HISTORY
FACTORY CONTACTS
The information in this sheet has been carefully reviewed and is believed to be accurate; however, no responsibility is assumed for
inaccuracies. Furthermore, this information does not convey to the purchaser of such devices any license under the patent rights to the
manufacturer. Measurement Specialties, Inc. reserves the right to make changes without further notice to any product herein. Measurement
Specialties, Inc. makes no warranty, representation or guarantee regarding the suitability of its product for any particular purpose, nor does
Measurement Specialties, Inc. assume any liability arising out of the application or use of any product or circuit and specifically disclaims
any and all liability, including without limitation consequential or incidental damages. Typical parameters can and do vary in different
applications. All operating parameters must be validated for each customer application by customer’s technical experts. Measurement
Specialties, Inc. does not convey any license under its patent rights nor the rights of others.