S32K144: How to configure I/O interrupts using SDK

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K144: How to configure I/O interrupts using SDK

2,442 Views
josehernandezcv
Contributor I

I'm trying to use I/O interrupts to toggle the state of a LED every time i click a switch, my code compile but the LED doesn't toggle, attach the code expecting someone tell me what i'm doing wrong. I'm working with S32 DS v2.0.

//Switch pin 12 PTC

//LED pin 16 PTD

/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "pin_mux.h"
#include "clockMan1.h"

volatile int exit_code = 0;

/* User includes (#include below this line is not maintained by Processor Expert) */

void INTE_ISR(void)
{
   PINS_DRV_ClearPinIntFlagCmd(PTC, (1<<12));
   PINS_DRV_TogglePins(PTD, (1<<16));
}

/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/


int main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Write your code here */
/* For example: for(;;) { } */

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);

PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

PINS_DRV_SetPinDirection(PTC, (1<<12), 0);
PINS_DRV_SetPins(PTD, (1<<16));

INT_SYS_InstallHandler(PORTC_IRQn, INTE_ISR, (isr_t *)0);

INT_SYS_EnableIRQ(PORTC_IRQn);

PINS_DRV_SetPinIntSel(PTC, (1<<12), PORT_INT_FALLING_EDGE);

while(1);

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/


#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

Labels (1)
5 Replies

376 Views
josehernandezcv
Contributor I

I was configuring wrong the type of edge, now the code works.

INT_SYS_InstallHandler(PORTC_IRQn, &INTE_ISR, (isr_t *)0);

INT_SYS_EnableIRQ(PORTC_IRQn);

PINS_DRV_SetPinIntSel(PORTC, 12, PORT_INT_RISING_EDGE);

0 Kudos

376 Views
pritampatil
Contributor III

I tried flashing this program, it is not executing properly. i got the following warning.

WARNING:   Description Resource Path Location Type
C:/NXP/S32DS_ARM_v2018.R1/S32DS/S32SDK_S32K14x_EAR_0.8.6/platform/devices/S32K144/include/S32K144.h passing argument 1 of 'PINS_DRV_ClearPinIntFlagCmd' from incompatible pointer type Interrupt_pin_PTC12 line 5044, external location: C:\NXP\S32DS_ARM_v2018.R1\S32DS\S32SDK_S32K14x_EAR_0.8.6\platform\devices\S32K144\include\S32K144.h C/C++ Problem

0 Kudos

376 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

You can use ProcessorExpert-PinSettings to skip this line:  PINS_DRV_SetPinIntSel(PORTC, 12, PORT_INT_RISING_EDGE);

pastedImage_1.png

Best regards,

Razvan

376 Views
pritampatil
Contributor III

Tried that too..

Still getting same warning message

0 Kudos

376 Views
raresvasile
NXP Employee
NXP Employee

Hi,

In your ISR:

void INTE_ISR(void)
{
   PINS_DRV_ClearPinIntFlagCmd(PTC, (1<<12));
   PINS_DRV_TogglePins(PTD, (1<<16));
}

change PINS_DRV_ClearPinIntFlagCmd(PTC, (1<<12)) to PINS_DRV_ClearPinIntFlagCmd(PORTC, (1<<12))

Let me know if it worked.

Best regards,

Rares

0 Kudos