KBI example on KE06Z

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KBI example on KE06Z

Jump to solution
1,015 Views
MLapaj
Contributor II

Hi, 

I've been trying to run example KBI project from newest KE06Z4 SDK (ver 2.8.0) but it does not seem to be working. 

In the said example, the pin used to generate rising edge is PTH0, while the KBI example pin is assosiated with register KBI0, bit 10, which is assigned to pin PTB2. Is that correct?

When running the example, the KBI interrupt does not occur. Shouldn't the GPIO pin be the same as KBI pin? However, it seems that initializing KBI on a pin keeps it from being used as GPIO, since I'm not able to toggle it's state. 

What am I missing here? Is the example correct and why does the interrupt not occur while running the example? Also, is it possible to use pin's GPIO functionality while also using it as KBI input?

0 Kudos
1 Solution
986 Views
mjbcswitzerland
Specialist V

Hi

If the example is configuring PTB2 as KBI input and PTH0 as output and toggling that I presume it expects you to physically connect the output (PTH0) to the input (PTB2 - or KBI0_P6) so that the test works.

Regards

Mark

 

View solution in original post

0 Kudos
5 Replies
1,007 Views
mjbcswitzerland
Specialist V

Hi

Try the operation using the open source uTasker project [https://github.com/uTasker/uTasker-Kinetis/tree/master/Applications/uTaskerV1.4] which has the following KBI interface and allows a single code to be used on almost all Kinetis parts. It simulates the Kinetis part and, in this case the KBI, so it makes debugging, learning and code reviews much simpler and efficient:

 

INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters
interrupt_setup.int_type = KEYBOARD_INTERRUPT; // define keyboard interrupt rather than IRQ
interrupt_setup.int_priority = PRIORITY_KEYBOARD_INT; // interrupt priority level
interrupt_setup.int_port = KE_PORTH; // the port that the interrupt input is on (KE_PORTE, KE_PORTF, KE_PORTG and KE_PORTH are the same)
interrupt_setup.int_port_bits = (KE_PORTH_BIT0); // the IRQ input connected
interrupt_setup.int_port_sense = (IRQ_RISING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive
interrupt_setup.int_handler = kbi_handler; // handling function
fnConfigureInterrupt((void *)&interrupt_setup); // configure interrupt

 

This configures a rising edge KBI interrupt on PTH0 - internally it maps this to KBI1_P24, as also shown by the user's manual:

 

mjbcswitzerland_0-1606313101272.png


https://www.utasker.com/kinetis/FRDM-KE06Z.html

When KBI function is enabled on one of the pins it overrides the GPIO function and so cannot be used as GPIO.

Below is the KE06 simulation showing the pin configuration on PTH0 - when this input is changed the interrupt is generated by the simulation.

Beware when using the KBI that if you configure more that one KBI input and one is active no other one will operate (will be ignored) until the first one is cleared - this makes the KBI of little use when multiple inputs need to be recognised together.

mjbcswitzerland_1-1606313156798.png

 

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

0 Kudos
1,003 Views
MLapaj
Contributor II

Thank you for your response, but I still don't quite understand if SDK example is correct and why is it not working properly for me, when flashing it onto KE06Z4.

0 Kudos
999 Views
mjbcswitzerland
Specialist V

Hi

If your example is configuring KBI0_P10 as input it will be on PTB2. PTH0 is not involved and there may simply be a bad comment in the code that confuses. Try PTB2 to see whether it interrupts.

You can also download the open source project and simulate your chip to help solve such issues - or simply use it for all development in order to have a more efficient solution.

Regards

Mark

 

0 Kudos
995 Views
MLapaj
Contributor II

I tried that and it didn't work. What confuses me is, what event should cause a rising or falling edge on KBI pin if I can't use it's GPIO functionality? To clarify it one more time: the SDK example is toggling pin PTH0 (configured as output) while expecting a rising edge on the pin assosiated with KBI0, bit 10 (which is PTB2) - please see the code below.

MLapaj_0-1606318686690.png

MLapaj_1-1606318723134.png

When I modified this code, to toggle pin PTH0, while also expecting the raising edge on the same pin, it turned out that I actually was not able to toggle PTH0 anymore (since, it lost it GPIO functionality).

What I'm trying to establish is if there is anyway to initialize KBI on any pin and also still be able to toggle it's state to trigger the interrupt? If not, does that mean that I should always use 2 completly defferent pins - one being used as GPIO and the other one with it's KBI function enabled?

0 Kudos
987 Views
mjbcswitzerland
Specialist V

Hi

If the example is configuring PTB2 as KBI input and PTH0 as output and toggling that I presume it expects you to physically connect the output (PTH0) to the input (PTB2 - or KBI0_P6) so that the test works.

Regards

Mark

 

0 Kudos