# Microcontroller Current Consumption when different internal and external clock modules are used simultaneously

I am using this Microcontroller - S32K142 64 pin.

From the Figure 4 in this Application Note, We can see there are 4 clock sources for the Microcontroller.

FIRC - 48MHz

SIRC - 8MHz

SOSC - 4-40MHz

LPO - 128kHz

SPLL - 112MHz

From the clocking tree diagram, Figure 4 in the application note attached, I can see that the core clock frequency of the Microcontroller can be derived from any one of the sources like FIRC, SIRC or SOSC and can be upconverted with the help of the SPLL.

My questions :

1. What is the maximum core clock frequency that the microcontroller SPLL can provide? Is it the 112MHz from the SPLL?

2. Objective is to calculate the current consumption due to different peripherals (Like I2C, SPI etc) and their clock module sources (like if I am using FIRC, SIRC and SPLL simultaneously)

Regarding current consumption - Suppose I use the 112MHz as the core clock frequency of the microcontroller i.e.HSRUN mode, from Table 13 of the datasheet,I get that, at 25degC, the current due to the oscillator is 112*360uA = 40.32mA? Isn't this a very high value? Am I correct in calculating the oscillator current, this way?

So, If I enable all the peripherals in HSRUN mode, my total microcontroller current consumption would be 52.2mA+40.32mA = 92.52mA. Is this correct?

But I am confused like, what about the current consumption due to FIRC & SIRC usage(suppose if I use FIRC & SIRC clock source also)? Suppose, I also use the FIRC module for some other peripherals, say like SPI at 48MHz. What would be the current consumption due to the FIRC module usage? Would it be 48*360uA = 17.28mA? And I use the SIRC for I2C Interface (downconverting the 8MHz SIRC to 400kHz). How to calculate the current consumption due to SIRC source?

(The 40.32mA current was only due to the HSRUN mode which derived its frequency from a external resonator of 8MHz and upconverted to 112MHz by the SPLL). So, should I add the currents as I am using 3 different clock sources (FIRC, SIRC and SPLL)?

Please help to clarify - to calculate the current consumption due to different clock source (FIRC,SIRC and SPLL) module usage and peripheral module usages?

• Jul 21 '20 at 17:04
• Yes could you please provide an answer for my edited question please. Really confused Jul 21 '20 at 17:09
• Please wait for someone to answer, asking people to answer isn't going to get your question looked at. I'll let someone else answer this question, I already spent about 20mins looking at it. I would reccomend the OP at least reads the datasheet and the app note all the way through. If you come up with a conclusion, I'll confirm it. Jul 22 '20 at 3:41
• What keeps you from trying all variants and measure the power consumption? Jul 22 '20 at 11:16
• You can get an estimate from the datasheet, it won't be close because they tested precise setups, the graph in the other question gives you a very good idea of what is possible. Building and testing is the best way to go Jul 22 '20 at 14:14

## 1 Answer

I had a quick look at the datasheet. I'm not familiar with this particular microcontroller, but I've used a lot of other Cortex M0/M3/M4/M7 chips, including low-power and high-speed ones. So I'll answer in slightly more general terms.

This microcontroller is described as an "ultra-reliable, general purpose automotive" device. That doesn't sound like low power to me; automotive comes with huge batteries :) If you're actually concerned about the difference between 40mA and 50mA current draw, this is probably the wrong device for you. Consider two questions: 1. Why do you care about power usage at all? and 2. Why this exact microcontroller?

The best low-power Cortex chips can draw about 10x less power or 5x less current than this while running at the same speed, and only draw a few nA in deep sleep mode (eg: STM32L4). This particular device isn't trying to be power efficient; it is probably optimized for something else. Low power is a tradeoff, it can cost you in other areas (speed, complexity, cost, ...). From your question, I think what you really need to do is go back to the drawing board and consider what is the actual spec: what does the device need to do? number of wakeups per second/amount of time spent running? how much power is available? and then your choice of device/family in light of the spec. Most likely, you either don't need to worry about power usage at all, or you need to make it the primary factor, including selecting a device primarily because of its power efficiency. Design usually starts from the spec, not from the device.

"What is the maximum core clock frequency that the microcontroller SPLL can provide?" - The SPLL can provide 160 MHz, see Table 34. SPLL electrical specifications. However the core can't run above 112 MHz. I'm not sure what happens if the SPLL is clocked too high for the core - it probably runs, but unreliably; that would be overclocking for microcontrollers. It may also be possible to clock some peripherals from 160MHz and clock the core from 160MHz/2.

"Objective is to calculate the current consumption due to different peripherals (Like I2C, SPI etc) and their clock module sources" - In general, the current consumption of different peripherals would just get added together to a total. The datasheet numbers for current may not be entirely accurate though, so if you really need accuracy (or if you need to know the worst-case) it is best to measure a batch of devices in a real-life scenario. Don't forget about current variation over operating temperature (higher at higher temperatures).

"Suppose I use the 112MHz as the core clock frequency of the microcontroller i.e.HSRUN mode, from Table 13 of the datasheet,I get that, at 25degC, the current due to the oscillator is 112*360uA = 40.32mA? Isn't this a very high value? Am I correct in calculating the oscillator current, this way?" - Yes, that's correct. The table says 40.5mA for that scenario, which is probably 40.32mA rounded up. No, it is not very high; it is just kinda mediocre for an ARM chip. Note that this is the current for oscillator and core, you could have the clock running with the core stopped, but it doesn't make sense to do that for very long.

"So, If I enable all the peripherals in HSRUN mode, my total microcontroller current consumption would be 52.2mA+40.32mA = 92.52mA. Is this correct?" - No, it's just 52.2mA total. Check the spreadsheet S32K1xx_Power_Modes _Configuration.xlsx to see which peripherals were measured.

"Suppose, I also use the FIRC module for some other peripherals, say like SPI at 48MHz. What would be the current consumption due to the FIRC module usage? Would it be 48*360uA = 17.28mA?" - No. The current/MHz for FIRC is not specifically listed in the datasheet, but at 48MHz it is probably similar to the STOP1 mode (clocked from FIRC) scenario in Table 13, 6.4mA.

"And I use the SIRC for I2C Interface (downconverting the 8MHz SIRC to 400kHz). How to calculate the current consumption due to SIRC source?" - I don't know; best bet is to measure it. It would probably be low compared to the other clocks since the speed is lower, a few mA.

"So, should I add the currents as I am using 3 different clock sources (FIRC, SIRC and SPLL)?" - Yes.

• Thank you very much for the very detailed answer @Alex I . I just have a few doubts from your answer. Please help to provide the clarification. 1. The Table 13. of the Datasheet only mentions the current consumption due to the "Core Clock" of the Microcontroller and not the other clock sources (Say FIRE, SIRC, etc). Am I correct? 2. And to calculate the current due to the Core clock, I would take the current in the Peripherals disabled column (40.5mA) and to calculate the current due to the peripherals operation, the current would be from peripherals enable column (52.2mA). Correct? Continued. Jul 29 '20 at 4:47
• @Newbie "So, 11.7mA is the current due to the peripherals. Is this correct?" Yes Jul 29 '20 at 7:40
• @Newbie "Vcc pin of microcontroller, I would take like - 52.2mA + 6.4mA + 2mA + 8mA (Current due to driving output pins of Microcontroller) = 68.6mA. Is my calculation correct?" Yes Jul 29 '20 at 8:09
• @Newbie "The Table 13. of the Datasheet only mentions the current consumption due to the "Core Clock" of the Microcontroller and not the other clock sources" - Not exactly; In Table 13 the VLPS column is with SIRC running, STOP1/2 column is with FIRC running (from Table 10) and HSRUN is from SPLL. I think it gives you the current for every clocking scenario Jul 29 '20 at 8:10
• @Newbie "If the table provides the current values for each clocking scenario, what is the need for the last column in the table 13, which is Idd/MHz?" - You could use that if you're running with HSRUN but at an unusual frequency eg 100MHz. Also, it is common to compare microcontroller efficiency using this number. Jul 29 '20 at 20:23