SPI or I2C for optimal energy consumption, EMI and EMC between MCU and Sensor - Page 1
Forum section: electronics / projects

author: Wilson__
author_rank: Frequent Contributor
timestamp: May 14, 2024, 09:46:44 pm
content: STM32 MCU links with sensor that hasthree connection modes, SPI 4 wires, SPI 3 wires and I2C.Whichmode, data clocking frequency and GPIO speed (4 settings, fast to slow)use minimumbatteryenergy, has bestEMI(electromagnetic interference) andEMC(electromagnetic compatibility) performance?Spacing between MCU and sensor is 15mm. Sensor data 60 bytes per second. Two layers PCB, 0.6mm thick. Only one sensor, no bus. MCU has enough pin. 3.1 volts for both chipMany thanks

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 14, 2024, 10:03:21 pm
content: Probably not I2C, due to the pull-ups. But depending on overall bit rate (length of transaction x how often polled per second) it could be an extremely narrow difference.On same board, EMC is irrelevant -- that depends wholly on layout and ground integrity. Short trace lengths mean source termination resistors aren't even important.Tim

author: ajb
author_rank: Super Contributor
timestamp: May 15, 2024, 03:49:13 am
content: Any difference in the power consumed by the interface itself may be swamped by other factors that depend on the sensor and what you're doing with the data. For example, configuring the GPIOs for higher speed (really, higher drive strength) will certainly consume more power, but if that lets you complete an SPI transaction faster and put the MCU/sensor to sleep sooner, maybe it's a net reduction in energy consumed. If you are trying to complete an operation quickly and get back to sleep, SPI will give a substantially shorter transaction, since it'll be higher speed and doesn't require addressing or start/stop signals. If by "mode" you mean SPI mode (clock polarity/phase), I can't see how that would make a difference, you will have the same number of bits and clock transitions in any case -- and likely you don't have much choice anyway, since you'll need to use a mode supported by the sensor.It's possible that the sensor could operate differently depending on the interface, for example if certain functions are only supported via one or the other, and that could have an impact on its power consumption as well. You'd really have to look at a lot of the details of the application to say anything for sure, but if there is a difference in energy consumption, I would bet SPI is the winner.

author: exmadscientist
author_rank: Frequent Contributor
timestamp: May 15, 2024, 04:43:39 am
content: Very general rules of thumb:1. I2C is kind of crap. If you have two design ideas, of roughly equal cost/complexity/general pain, and one uses I2C and one doesn't, it's probably best to choose the other one. (But there are a lot of I2C parts out there and they do bring advantages, so the general-pain-level is rarely equal.)2. Most problems with I2C arise when it leaves your PCB. If you can keep I2C on your board, you probably don't need to worry too much about it. Probably. Conversely, if you are planning to take I2C off-board to any significant degree, it can be worth investing a lot of time into either not doing this or doing it carefully.

author: Wilson__
author_rank: Frequent Contributor
timestamp: May 15, 2024, 07:35:31 am
content: What ballpark SPI clock frequency you'feel' comfortablein this case?0.5 to 10 MHz sounds right???MCU and sensor rated 24MHz and 17MHz. PCB trace 15mm and is short in wavelength of un-wanted emission antenna.Driven cap 10pF. 5pF MCU pin, unspecified on sensor, and pcb trace capacitance (0.75pF per 15mm)Faster SPI clock means chips can finish and back to sleep sooner and save waken time battery usage. But, not want to get too high that it generate too much EMI.Many thanks

author: dietert1
author_rank: Super Contributor
timestamp: May 15, 2024, 07:37:20 am
content: I2C is half the pin count in case it matters. SPI pin count increases with the number of devices. At least one extra pin per device. Sometimes a device needs an interrupt pin in addition to its chip select.SPI is 100x or so faster.In very low power designs the power consumption of I2C pull-ups and the increased up-time of the CPU matter.Regards, Dieter

author: tszaboo
author_rank: Super Contributor
timestamp: May 15, 2024, 07:44:58 am
content: Quote from: Wilson__ on May 15, 2024, 07:35:31 amIf it's a 4 layer board with a full GND and VCC plane, you can easily run it at the full rated speed. Verify the end result with a scope, decrease it only if it's marginal on the timing characteristics.The EMI generated is the same, since what makes the most EMI is the edge rate of your digital signals, not your clock rate.Quote from: dietert1 on May 15, 2024, 07:37:20 amOn low power systems, you make the I2C transactions with a DMA and a sleeping core.