I'm trying to understand something about reading the GPIO PDIR. In the reference manual, it says:
The GPIO input data register displays the logic value on each pin when the pin is configured for any digital function,
provided the corresponding Port Control and Interrupt module for that pin is enabled.
Am I to understand that the KBI module has to have the pin interrupt enabled to read the state of the pin when it is configured as an input? I was able to read back the input state once I enabled the input in the PIDR register. I had been having some problems reading it, but I think it was the debugger being flaky and not reporting things correctly. I was just looking for clarification on what it means by enabling the interrupt module.
Solved! Go to Solution.
David
I believe that the details about "Port Control and Interrupt Module" in the KE06 user's manual can be ignored because it looks to be text taken from the K-series devices which have a Port Configuration module (which then contains interrupt capabilities).
The KE devices don't have this module and the pin multiplexing is 'hard-wired' depending on enabled peripherals.
However there is a GPIOx_PIDR register which the K series doesn't have which needs to be configured before inputs are sampled. Each input is disabled by default (meaning that its value is not sampled and so the value in GPIOx_PDIR doesn't follow it) so clearing its bit in that register allows its state to be subsequently read.
Practically:
1. The ports don't need to be enabled (no peripheral clock needs to be enabled to them)
2. To be able to read the input state the bit in GPIOx_PIDR needs to be set to '0'
3. The present input state can then be read via GPIOx_PDIR
Regards
Mark
Hi David,
The GPIO and KBI are separated modules. The GPIOx_PDIR register is used to read GPIO pin input status, which only used for GPIO pin as input pin.
And KBI is pin another function, which is different from GPIO function using KBI module related register and generated related interrupt.
Wish it helps.
best regards
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks, but did you read my question? I know what the KBI and GPIO modules do. The KE06 Reference Manual clearly says on page 677:
The GPIO input data register displays the logic value on each pin when the pin is configured for any digital function,
provided the corresponding Port Control and INTERRUPT MODULE FOR THAT PIN IS ENABLED.
So, what does it mean by enabling the interrupt module of that pin? I do not want to cause an interrupt, I just want to read the state of the pin.
David
I believe that the details about "Port Control and Interrupt Module" in the KE06 user's manual can be ignored because it looks to be text taken from the K-series devices which have a Port Configuration module (which then contains interrupt capabilities).
The KE devices don't have this module and the pin multiplexing is 'hard-wired' depending on enabled peripherals.
However there is a GPIOx_PIDR register which the K series doesn't have which needs to be configured before inputs are sampled. Each input is disabled by default (meaning that its value is not sampled and so the value in GPIOx_PDIR doesn't follow it) so clearing its bit in that register allows its state to be subsequently read.
Practically:
1. The ports don't need to be enabled (no peripheral clock needs to be enabled to them)
2. To be able to read the input state the bit in GPIOx_PIDR needs to be set to '0'
3. The present input state can then be read via GPIOx_PDIR
Regards
Mark
Thanks for the clarification, Mark. I did think it was strange that the KBI would have to be enabled just to read the pin state, and it does seem to be working without it.
David
Unfortunately I haven't yet used the KBI so can't comment on it more than saying that I "believe" that it can be used to achieve GPIO interrupts. The K and KL series have port interrupts built into the port configuration module and so such port interrupts are otherwise missing on the KE parts (hence my belief that the KBI fills in here if needed - available on quite a lot of ports bits (but not all); there is also the IRQ input but this is much more limited).
Regards
Mark
Update 7.1.2015:
- KBI support has now been integrated int the uTasker project for KE02/KE04Z40, KE04 and KE06 including simulation. There is a reference at http://www.utasker.com/kinetis/FRDM-KE06Z.html