Hello NXP engineer:
As indicated in the subject, my peripheral circuit has a pull-up resistor. I want to configure the IO as open-drain when not using the pin, providing output through the pull-up resistor. When the pull-up output is not needed, I want to pull the level low to 0V through the pin. I'm wondering if this can be achieved on the S32K1; the pin I'm currently using is PTB12.
If this function can be implemented, how should I configure my components and write the program?
Hi,
the ports in the GPIO mode do not support Open-drain. It is only available when a port is routed to a module that supports that, like LPI2C.
The easiest workaround could be configure the pin as input, initialize output value in PDOR register as ‘0’ and then use register PDDR (Data Direction) to switch between levels (either Hi-Z or ‘0’ output). The only disadvantage is that you need to ensure that the output value in PDOR register is not set to ‘1’ by mistake because it would lead to short circuit, depending on circuit connected.
BR, Petr