SPI single line SDI/SDO

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
Hi,
I'm trying to figure out the wiring of a Accelerometer Module (MMA7455).
It's a module with a single data line for SDI/SDO. how does
it interface with a PIC which has a separate SDI and SDO ?
Do I need to connect them together and add a Schottky Diode as suggested here :
http://forums.netduino.com/index.php...h-the-mma7455/
?

Thanks, Amitai
 

Anish

Feb 5, 2011
46
Joined
Feb 5, 2011
Messages
46
Provide your full information such as what accelerometer module you exactly use? / the datasheet?
The accelerometer IC itself is made by freescale and it does have SDI and SDO pins. But what make of the module do you have?
Btw, the above link you posted is dead
 

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
Thanks Anish, here are the details.
The pic which I'm using is pic16f877:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010241
and the accelerometer details are in this link:
http://www.parallax.com/product/28526
and the fixed link:
http://forums.netduino.com/index.php?/topic/7270-spi-learning-with-the-mma7455/

I want to use the accelerometer for a simple purpose of a motion movement
indication at the Z axes (up/downwards). I know that the accelerometer is
intended and can do much more then that but I didn't find something else
which will suit my needs and I see in the data sheet that it can be used for
this purpose.
Meanwhile I'm also checking the option of I2C..

Amitai
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
From the datasheet of the MMA7455, page 18, you can see the sequence of the transfer for both read and write to the chip.
The easiest way to do this is to use a diode between the PIC's SDO to the SDI/SDO line from the 7455 and connect the PIC's SDI line to this common point. The diode's cathode against the SDO output, acting in 'sink' mode. The pullup on the dataline will keep the line high and the SDO output will pull it down via the diode, when transmitting.
You will need to 'send' a dummy last high bit in the command byte and a dummy byte from the PIC to transfer / read the 7455, since the PIC is the master and generates the clock. This dummy bit must be high '1', and the byte must contain only '1's, or have the value 0xFF. If this is not set to '1' any '0' sent from the SDO will interfere with the received data from the 7455.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
In section 9.1 on page 69 of the PIC16F877 data sheet, the text before the last bulleted list says "For the pins to behave as the serial port function, some must have their data direction bits (in the TRIS register) appropriately programmed" and the second bullet point says "SDO must have TRISC<5> cleared". This implies that you can control whether the RC5/SDO pin is an output or not using TRISC bit 5.

If that's the case, you can set the RC5/SDO pin (SDO aka MOSI) to input mode by setting bit 5 of TRISC, without affecting the SPI peripheral. This means you should be able to connect the SDO/MOSI and SDI/MISO pins together. When you're transmitting a byte, clear TRISC bit 5; when you're receiving, set TRISC bit 5.

However, Figure 3-5 on page 33 shows that the output enable control of RC5 is controlled by the output of the TRIS latch ORed with a signal called "Peripheral OE". This implies that the peripheral can force the pin to output mode, although it doesn't say where the "Peripheral OE" signal comes from for RC5.

You might have to ask Microchip technical support if you need an answer on whether RC5/SDO can be put into input mode using TRISC bit 5 without disrupting the SPI peripheral.

In any case you'll need to check the exact timing and phase of the clock and data signals used by both the PIC and the accelerometer to make sure that everything happens when it's supposed to. gorgon mentions the need for a dummy bit in the command byte. I haven't looked into this, but you need to.

I think you also have to enable SPI 3-wire mode by setting the SPI3W bit, bit 5, in the Mode control register (register 0x16) before you can do any other communication with the device. This is mentioned in item 2 in the Quick Start guide on the last page of the module documentation.
 
Top