Firstly, Hello to all, I am trying to design a circuit for automotive application that circuit will read positive and negative input signals in the same pin via selecting the type of input in the software. I designed a prototype circuit to do it.You can see it in this picture.
I refered a digikey article. Link of the article is here Protecting Inputs in Digital Electronics. When I want to read positive signal (9 V - 32 V). I will set internal pull-down resistor and input will be active high. When I want to read negative signal (0 V) I will set internal pull-up resistor and input will be active low. Internal pull-up and pull-down resistor value of the STM32F042C6 vary between 25k to 55k but typical value is 40k. Do you have any recommendation to improve design of the circuit ?
Edited:
If I don't use pull down resistor.While reading positive signal.The capacitor(C1) will not be discharged after I switch(SW1) from positive signal to floating(not connected) and I will still read it as a high input.In this picture you can see that the input of the mcu is hanging arround 2.96V when the input not connected and the pull down resistor not selected.Is there any way to solve this problem without using pull down resistor?