Why 2.2M? The inputs have a leakaje of 200nA at worst. Most 50nA.
Pullups are 45K, it could be too much current depending on your application.
But if enable them before reading, and after then disable again, the power draw will be minimal.
The best would be to set PC4 as output high level, wait few uS, read the inputs, set PC4 as input and leave.
That way no power being wasted anywhere while not reading. Those pins are not going to consume anything.
In most stm32 you can set the pins as analog (Not adc related), that way they're completely disconnected from anything.
It isn't input, neither output, just nothing.
I think your problem is that you're not waiting enough time for the input pin capacitance to get charged.
Each pin is about 5pF. If you calculate RC constant for 2.2M and 3.3V is 11us!
And for 98% of the voltage you need 5RC, so 55uS.
How many time does counting to 10 take? I doubt anything close to 50uS!
And I hope the compiler is not doing it even worse by optimizing the loop!
for(i = 10; i; i--)
{
__no_operation(); // wait
}
Try yourself, how many time it takes. Something like:
// Start Ex. Timer 1, configured at the same speed as the core.
PC4 = 1; // Enable output
while(!SENS_1 || !SENS_2 || !SENS_3); // While any input is read low
// Stop timer here. (But don't clear it)
// Read Timer counter value, convert into time, and adjust your loop with 50% extra time for safety.
// Ensure to do it few times to get a consistent result.
I would just connect it with something lower like 100K, 5RC will be 1.5uS.
And for 10K, 5RC would be 250nS. How often are you going to read the inputs?
If it's battery critical, I guess the MCU will be in sleep most of the time.
Guessing you read the inputs maybe 20 times a second.
You use 10K values, wait 4uS every time, read and disable, let's say it takes 5uS.
That's 100uS/second.
With 4x10K you get 1.32mA peak consumption. The resistors will draw 1 second of power every 2.7hours.
For 1 hour and consume 1.32mAh, it would take almost 14 months!