How to tristate an output pin on KL03

Showing results for 
Search instead for 
Did you mean: 

How to tristate an output pin on KL03

Contributor I

I am a bit confused by the manual when it is describing the GPIO behavior with regard to input/output buffers. 

I am reading from the KL03 Sub-Family Reference Manual Chapter 12 (PORT Control and Interrupts). Section 12.7.1 has the following sentence: "A pin can be floating due to an input pin that is not connected or an output pin that has tristated (output buffer is disabled)".

The problem with the statement above is that KL03 does not appear to have a register in the PORT module that would enable or disable an output buffer. Would someone help me understand what was meant by the statement above and how can I set the output pin to Z / High Impedance / Tristate?

Here is how I set everything up right now:

//Enable PORTB clock


//Initialize PB0 as GPIO


//Set PB0 as output direction

GPIOB->PDDR |= (1U << 0U);

//Set PB0 to level HIGH

GPIOB->PDOR |= (1U << 0U);

//Need help setting PB0 to high impedance state

0 Kudos
1 Reply

Specialist V


The reference is general and some peripheral functions (such as FlexTimers, SPI, I2S) can tri-state outputs as part of their normal operation. The reference is not specific to GPIO output mode, where there is no control to tri-state a "GPIO output" itself. To tri-state a GPIO configure pin you need to sets its direct to input and remove any pull-up/down resistors.

In the uTasker project your code sequence is done with:

_CONFIG_DRIVE_PORT_OUTPUT_VALUE(B, (PORTB_BIT0), (PORTB_BIT0), (PORT_SRE_SLOW | PORT_DSE_HIGH)); // configure clock gating, set output and characteristics and drive to '1'

_FLOAT_PORT(B, PORTB_BIT0); // set to floating input

Port macro overview:

Macros also use bit-banding or bit-manipulation engine for maximum efficiency.



Kinetis KL02/KL03/KL05:

For less questions and faster, cheaper developments: try uTasker for Kinetis (also free open source on Git Hub)

0 Kudos