Hello!
I'm fighting a strange behavior in what should be a very simple situation:
- MCU MKE02Z16VLD2;
- I need to use 2 pins (PTB1, PTB2) alternately as Input and Output;
- When using them as Inputs, my external drive is very low current, so I rely on the MCU having a very low leakage current. Datasheet say this current is typically 0.1uA, max 1uA;
- When testing the circuit, the external drive was not capable of driving the MCU pins. Further search showed the port leaking a much higher current - in the order of 100uA;
- For a test circuit, I connected each pin to a pair of resistors, 33k, to GND and VDD, making in effect a load near 100uA when driven High or Low;
I compiled and ran this test code:
for (;;)
{
FGPIO_PCOR_REG (portIO) = maskIO2 | maskIO3; // IO LO
FGPIO_PDDR_REG (portIO) |= (maskIO2 | maskIO3); // IO Output 0.008
FGPIO_PDDR_REG (portIO) &= ~(maskIO2 | maskIO3); // IO Input 0.187
FGPIO_PSOR_REG (portIO) = maskIO2 | maskIO3; // IO HI
FGPIO_PDDR_REG (portIO) |= (maskIO2 | maskIO3); // IO Output 3.321
FGPIO_PDDR_REG (portIO) &= ~(maskIO2 | maskIO3); // IO Input 2.736
}
Single stepping through this code, I measured, after each line execution, the voltages shown at the right:
- After driving the pin Low and reverting it to Input, it remains at a very low voltage;
- After driving the pin High and reverting it to Input, it remains at a very high voltage;
- A short circuit to the opposite rail, by means of a current meter, show the current to be around 100uA, also.
I must say I'm stuck! No idea why this is happening. I would appreciate anyone pointing out where am I busting it!