This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

3 wire SPI with TM4C129ENCPDT

Other Parts Discussed in Thread: TM4C129ENCPDT, EK-TM4C129EXL, LAUNCHXL-F28069M, LAUNCHXL-F28027F

Hi everybody,

I am trying to make TM4C129ENCPDT mcu's SSI interface to work in 3 wire SPI configuration.

I have the launchpad EK-TM4C129EXL and an Infineon magnetic angle sensor TLI5012B E1000. This sensor communicates with the mcu over a 3 wire SPI interface, the sensor being in slave mode. There are the obvious clock and slave select lines and only a single data line is available for a bi directional, half duplex communication.

At first sight In advanced SPI modes, one of the SSI data lines of  TM4C129ENCPDT mcu can be configured as a bidirectional data line but in advanced SPI mode, a single data word size can NOT be set to 9 bit  which is what this sensor needs.

Another option, may be to connect the sensors data pin to mcu's SPI  RX pin and then connect mcu's SPI TX and RX pins together through a few kohm resistor. I haven't gone far enough yet to know about how this configuration can be made to work in software side though. 

I am trying to decide whether should I continue to work on this couple or should I look for another mcu sensor combo.

Since this is my first post I'll give a little info about myself ;  I am experienced in induction motor control and dsPIC motor control processors with a preference of assembler over C whenever I can. This is my first project with a TI processor and I started to like it. So I am climbing another steep learning curve again in many levels.

I am not asking someone to feed me with a complete solution. Any idea or a bit of info will be appreciated.  

Thanks for reading.


 

  • Hello Kerem

    Connecting the SPI RX and TX pins would not be possible in legacy mode. The reason being that the TM4C does not explicitly support half duplex. So the TX and RX pin would always create a bus contention. You may want to look at MCU's which support Half Duplex Mode.

    The other option is to bit bang the IO's outside the scope of the SPI controller. This is the only reliable, easy path for communication between the sensor and the MCU.
  • Another possibility would be to split it into two transactions, one for the initial write, one for the response. You'd need a little bit of glue logic and the ability to set the word size to an odd value, but it should work. Bit banging might still be easier though, even if the split SPI approach was faster.

    One question Kerem, how quickly do you need to read from the sensor? That might determine if you can use a bit banging solution.

    One other question, most of the SPI peripherals I've seen will work with multiples of 8 even when they have an optimized odd size, Does this sensor allow that?

    Robert
  • Not the legacy but advanced mode allows half duplex on a pin, as far as I understand, then 9 bit word size becomes a problem.

    I don't want to take the bit bang route, since I am at the beginning of the project. I better look for another MCU or sensor.

    Thanks Amit.
  • Hello Kerem

    Yes that is correct. The advanced mode operates in 8-bit boundary. The Bi mode allows for half duplex, but then bits will be shifted in corresponding to two data lines leading to data management overhead.
  • I am also looking for a way to implement a two back to back, one send and one receive transaction as you suggest. For the glue logic a circuit like in this link may be used;

    www.totalphase.com/.../200350046-Interfacing-with-3-wire-SPI

    Speed will be a little over 5 kHz and four 9 bit words will be received from sensor but as in my reply to amit I rather choose another sensor or MCU instead of bit banging.

    This sensor strictly needs 9 bit word size. One regular 8 bit data + 1 more indicator bit telling whether it is a data or control word. It does not allow it to be padded up to 16 bit.

    Thanks Robert.
  • Hello Kerem

    Not being partial to TM4C, choosing another sensor would be a better choice.
  • Good old microwire, that approach will likely work. I'd want to try before committing to it. Five 9 bit words so 45 bits total for the transaction. You can probably use 48 clock cycles (6 bytes) and then parse out the result.

    Robert
  • TM4C123 variant has a built in microwire capability but I think I found my solution.

    I was keeping an eye on C2000/Piccolo devices for my motor control projects while I am using dsPICs and recently I ordered both LAUNCHXL-F28069M and LAUNCHXL-F28027F launchpads with some spare MCUs.

    Guess what I figured out last night? Piccolo SPI has the exact 3 wire capability that I need; Single bi-directional data pin is available and data size can be set to any number in between 1 and 16, perfect ! So I am switching to Piccolo MCUs while keeping my sensor.

    Good thing is; after this project a new motor control project will follow. Now I can do both projects on one MCU, piccolo.

    Bad thing is; TM4C129EN has a good IoT capability and it is an ARM processor which I want to have experience in both. That's why I wanted to do it with TIVA in the first place. I was getting comfortable with Tivaware.

    It's been proven once again that I can't get everything I want in one package.

    Thank you Amit and Robert, your inputs helped me to arrive a conclusion faster.
  • I need to correct myself. This sensor's word length IS 16 bits wide ! Not 9......

    I think I was remembering another 3 wire setup from past. 4 wired SPI is pretty standard but 3 wire means many different things appearently.
  • Hello Kerem

    Thanks for correcting the bit length. Best of luck with the Piccolo class.