1
\$\begingroup\$

In current design I have ADS114S08 on SPI and LSM6DSO32TR on I2C. However I am short of MCU pins and IMU is capable of 10MHz SPI too. The only problem is that ADC chip only supports mode 1 (CPOL = 0, CPHA = 1), and IMU "is compatible with SPI modes 0 and 3".

I am thinking, what if I put an inverter with short propagation delay between clock line and SPC input of the chip? That should theoretically make it mode 3 (CPOL = 1, CPHA = 1) for the device.

Surprisingly, I did not find any such solutions on the web. The 8-years old question here has only suggestions to switch modes on the fly. However there is a short comment there that at least shows I am not the first one with this idea.

Has anyone tried this?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Why add hardware if you just can change the SPI mode to correct one in software before starting communication wih a device? Which MCU you have? Also, SPI mode numbers or CPOL/CPHA bits are not universal. You must check from each chip what each mode means. \$\endgroup\$ Commented Dec 11, 2022 at 8:36
  • \$\begingroup\$ I am planning on using STM32G431KxT. The chip is rather small for cramming in CANOpen stack, 4 motor control PWM channels and IMU, ADC and UART communication. A single SOT353 inverter on the other hand is nothing in PCB space and BOM. If it can save me a few lines of code and clock cycles I'll take it in a heartbeat. I did check the datasheets for SPI timing, that's what gave me an idea to flip the SCK. \$\endgroup\$ Commented Dec 11, 2022 at 9:27

2 Answers 2

1
\$\begingroup\$

If you have checked the timings or MCU and both chips about their mode or CPOL/CPHA bits which will vary between devices, then you can have a hardware solution.

But changing the mode is just one register write. Which needs to be done while SPI is disabled, but the STM32 HAL should do that already. The only drawback is that timings must be obeyed, i.e. the setup and hold time of clock related to chip select.

The drawback of hardware solution is that you have to live with it and take it always into account. For example it may be important if the chip power must be turned off, as you cannot have a state where clock for both chips is low. Unless the clock inverter power is turned off with the chips.

So either solution is fine. It just depends on if you want to add an hardware inverter or just a couple lines of code, and you likely will have device specific SPI fuctions anyway.

If you really want a hardware solution, then next step is to determine is which mode you will use on MCU and which chip gets the clock via inverter.

Just make sure the data outputs on the chips go into high impedance mode so that they can be on the same bus.

\$\endgroup\$
0
\$\begingroup\$

My approach would just be to select the right mode for each device before asserting it's enable pin.

Only if that didn't work I'd consider adding an inverter in the clock line

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.