AnsweredAssumed Answered

simple GPIO interrupt example ?

Question asked by John Beale on Nov 16, 2015
Latest reply on Nov 16, 2015 by Alice_Yang

I am using a Kinetis KL16Z128 processor, developing with KDS 3.0.0 and KSDK 1.2.0 / Processor Expert.  I am looking for a simple project code example of a GPIO input pin triggering an interrupt.  Is there one I can look at?  So far I have:

 

Component Inspector:

  gpio1:fsl_gpio    Input pin "SYNC_IN" Interrupt/DMA: Interrupt on falling edge

 

main.h: 

  extern volatile uint32_t syncCount;

 

main.c:

  syncCount = 0;  // count of sync line input signals (updated in interrupt routine)

  INT_SYS_EnableIRQ(PORTA_IRQn);

  INT_SYS_EnableIRQGlobal();

  do { various stuff... } while ( 1 );  // main loop

 

events.c:

  void PORTA_IRQHandler(void) {

    PORT_HAL_ClearPortIntFlag(PORTA_BASE);

    syncCount++;

  }

 

This compiles OK, and it runs, but I never see syncCount increment from 0, even though I am generating pulses on the PTA_4 input pin ("SYNC_IN") which I can detect using a normal port read from the main.c using  GPIO_DRV_ReadPinInput(SYNC_IN).

 

I have read through the document Interrupt handling with KSDK and Kinetis Design Studio  and it has useful information, but not quite enough for me to get a project working.  Any suggestions would be appreciated. Thank you!

Outcomes