AnsweredAssumed Answered

Hard Fault in keyboard interrupts

Question asked by Guilherme Romero on Dec 26, 2014
Latest reply on Dec 26, 2014 by Mark Butcher

Hello, Good day!

 

I am developing with microcontroller MKE04Z8M4 and I am trying to use interrupts that are generated by the keypad. These interrupts are related to the pins: PTA0, PTA1, PTA2, PTA3, PTB0, PTB1, PTB2 and PTB3. To perform my test I am using PTB0 pin.

 

However, I have difficulties using the resources of the KDS tool (Kinetis Design Studio). It doesn't provide a "Bean" for the keyboard interrupts.

 

I'm using the feature "Init_KBI", found in "Components Library / Categories / CPU Internal Peripherals / Peripheral Initialization / Init_KBI ". After creating that component, I configure its property "Component Inspector - KABI0" as follows:

 

Settings :

“Clock gate” : “Do not Initialize”

“Detection mode” : “edges only”

And in all Pin Sensitivity I leave as : “Falling edge or low level”

 

Pins/Signals

    I enable this option only for pin 4

    “Input pin 4” : “PTB0”

    “Input pin 4 signal” : “KBI0_Pin_PTB0”

 

Interrupts

“Interrupt request” : TRUE

“Interrupt priority” = 0

“ISR name” = “Int_ISR”

“KBI_Interrupt” = TRUE

 

Initialization

    “Call Init method” = TRUE;

 

After having set the component "Init_KBI", I use the feature "Generate Code Processor Expert" and get the following result:

    Components

     KBI0:Init_KBI

      Init_ISR

     Init

    PDD(directory)

   

A module was created to initialize KDB0 like this:

void KBI0_Init(void)

{

  /* KBI0_SC: ??=0,??=0,??=0,??=0,KBF=0,KBACK=0,KBIE=0,KBMOD=0 */

  KBI0_SC = 0x00U;

  /* KBI0_ES: KBEDG=0 */

  KBI0_ES = KBI_ES_KBEDG(0x00);

  /* KBI0_PE: KBIPE=0x10 */

  KBI0_PE = KBI_PE_KBIPE(0x10);

  /* KBI0_SC: KBACK=1 */

  KBI0_SC |= KBI_SC_KBACK_MASK;

  /* KBI0_SC: KBIE=1 */

  KBI0_SC |= KBI_SC_KBIE_MASK;

}

 

And below this function, there is a commented code block referring to an ISR:

 

/*

** ###################################################################

**

**  The interrupt service routine(s) must be implemented

**  by user in one of the following user modules.

**

**  If the "Generate ISR" option is enabled, Processor Expert generates

**  ISR templates in the CPU event module.

**

**  User modules:

**      main.c

**      Events.c

**

** ###################################################################

PE_ISR(Int_ISR)

{

// NOTE: The routine should include actions to clear the appropriate

//       interrupt flags.

//

}

*/

 

And, obeying the comment, I'm putting that function in module "Events.c". After these procedures I build the project, start the debugger, boot up and execute the code Step by Step. As I enter the function "KBI0_Init" a Hard fault error happens. It seems the

 

compiler doesn't recognize my ISR, although it appears at the interrupt vectors table. I couldn't find the solution to this problem. Has someone managed to use keyboard interrupts for this chip using the KDS tool?

Outcomes