S32k344-wb Rising Edge Interrupt.

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

S32k344-wb Rising Edge Interrupt.

204 Views
koen_Intercel
Contributor I

Dear Experts,

We are making an HVBMS and decided to order some hardware to get familiar with the NXP ecosystem. Ultamatly we want to have a HVBMS but to start we just want some simple functions on the Whiteboard( S32K344-WB ). I've divided this relative simple quest in multiple parts.

  1. Setup,
  2. Followed Training,
  3. Code,
  4. whishes

 

1. Setup

I'm 'writing' the code in S32 Design studio version 3.4 because the examples of the whiteboard are in this IDE. (Build id: 201217 (Update 3)).
My project name is H_bridge_Example it uses the following SDK's

  • FreeMASTER_S32K344 - Version 3.0.0
  • PlatformSDK_S32K3_2022_03 - Version 2.0.0

I'm debugging with an GDB server locally. With an J-Link debugger.

 

2. Followed Training

i've found a training document called "06_S32K3xx_Pins_and_Clocks_with_RTD_Training", it talks about setting up the ISR with an interrupt on button 3. Using the Siul2_Icu, i've followed the following steps of this training.

  1. Setting the pin (C20) as an input (Connected to the button), and connect it to the eirq 16. Giving it a label and Identifier as "USER_BTN2".
    1. Outpub buffer enable Disabled
    2. Safe mode control disable
    3. input buffer enable Enabled
    4. Pull select Pulldown
    5. Pullup enable Enabled
    6. Output Inversion Select Dont't invert
    7. Pad Keep enable Disabled
    8. Driver strngth N/a
    9. Input filter Enable N/A
    10. Inatial Value n/a
    11. touch sensing n/a
  2. I've added the Siul2_Port driver And Siul2_Dio.
  3. In the main loop i've set the Siul2_port_ip_init & Siul2_Port_Ip_SetInputBuffer. (See 3. Code)
  4. With the Siul2 ICU i've added an HWInterruptConfigList from IRQ_CH_16 to IcuHwIntrruptConfigList_0.
  5. IciSiul2: Siul2 instance 0, ICU External Iterrupt Filter clock prescaler 2
    1. Name IcuSiul2Channel16
    2. Hardware channel 16
    3. ICU External enable Intrrupt filter True
    4. ICU Exernal Intrrupt filter Setting.
  6. Icuchannels: ChannelRef "/Siul2_Icu/Siul2_Icu/Siul2ConfigSet/IcuSiul2_0/IcuSiul2Channel_16"
    1. ICU_Rising_Edge
    2. ICU_MODE_SIGNAL_EDGE_DETECT
    3. 0: IceSignalEdgeDetection
    4. IcuSignalNotification "Usr_Btn_Callback"  <-- Callback function.
  7. I've added the IntCtrl_IP. (Wasnt in the tutorial)
    1. In the interupt controller i've enabled the Siul[0..3]_IRQn with priority 3
  8. In de code ive added: (See 3. Code)
    1. Siul2_Icu_Ip_Init
    2. Siul2_Icu_Ip_EnableInterrupt
    3. IntCtrl_Ip_InstallHandler
    4. IntCtrl_Ip_EnableIrq

3. Code:

Main.c:

#include "Mcal.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"

// Interupts
#include "Intctrl_Ip.h"
#include "Siul2_Icu_Ip.h"

ISR(SIUL2_EXT_IRQ_16_23_ISR);

volatile int exit_code = 0;
/* User includes */

void Usr_Btn_Callback(void){
	Siul2_Dio_Ip_TogglePins(LED1_PORT, LED1_PIN);
	return;
}

int main(void)
{
	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);   // Set Ports

	Siul2_Port_Ip_SetInputBuffer(PORTC_H_HALF, USER_BTN2_PIN, TRUE, *(g_pin_mux_InitConfigArr0[4]).inputMuxReg , *(g_pin_mux_InitConfigArr0[4]).inputMux ); // Set input of C20

	// Set ISR
	Siul2_Icu_Ip_Init(SIUL2_ICU_IP_INSTANCE, &Siul2_Icu_Ip_0_Config_PB_BOARD_InitPeripherals);
	Siul2_Icu_Ip_EnableInterrupt (SIUL2_ICU_IP_INSTANCE,(*Siul2_Icu_Ip_0_Config_PB_BOARD_InitPeripherals.pChannelsConfig)[0].hwChannel);
	IntCtrl_Ip_InstallHandler(SIUL_0_IRQn, SIUL2_EXT_IRQ_16_23_ISR, NULL_PTR);
	IntCtrl_Ip_EnableIrq(SIUL_0_IRQn);


    for(;;)
    {
        if(exit_code != 0)
        {
            break;
        }
    }
    return exit_code;
}

Siul2_Port_Ip_Cfg.c:

const Siul2_Port_Ip_PinSettingsConfig g_pin_mux_InitConfigArr0[NUM_OF_CONFIGURED_PINS0] =
{
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 89u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_DISABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_ENABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .initValue                   = 0u
    },
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 91u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .driveStrength               = PORT_DRIVE_STRENTGTH_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_DISABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_ENABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .initValue                   = 0u
    },
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 217u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .driveStrength               = PORT_DRIVE_STRENTGTH_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_DISABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_ENABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .initValue                   = 0u
    },
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 216u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .driveStrength               = PORT_DRIVE_STRENTGTH_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_DISABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_ENABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .initValue                   = 0u
    },
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 84u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_DOWN_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_ENABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_DISABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .inputMuxReg                 = {
                                         32u
                                       },
        .inputMux                    = { 
                                         PORT_INPUT_MUX_ALT3,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT,
                                         PORT_INPUT_MUX_NO_INIT
                                       },
    },
    {
        .base                        = IP_SIUL2,
        .pinPortIdx                  = 171u,
        .mux                         = PORT_MUX_AS_GPIO,
        .safeMode                    = PORT_SAFE_MODE_DISABLED,
        .inputFilter                 = PORT_INPUT_FILTER_DISABLED,
        .pullConfig                  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .pullKeep                    = PORT_PULL_KEEP_DISABLED,
        .invert                      = PORT_INVERT_DISABLED,
        .inputBuffer                 = PORT_INPUT_BUFFER_DISABLED,
        .outputBuffer                = PORT_OUTPUT_BUFFER_ENABLED,
        .adcInterleaves              = { MUX_MODE_NOT_AVAILABLE, MUX_MODE_NOT_AVAILABLE },
        .initValue                   = 0u
    },
};

Siul2_Icu_Ip_SA_BOARD_InitPeripherals_PBcfg.c:

const Siul2_Icu_Ip_ChannelConfigType Siul2_Icu_Ip_0_ChannelConfig_PB_BOARD_InitPeripherals[1U] =
{
    /** @brief IcuSiul2Channel_16 */
    {
        /** @brief Siul2 HW Module and Channel used by the Icu channel */
        16U,
        /** @brief Siul2 Digital Filter enable */
        TRUE,
        /** @brief Siul2 Digital Filter value */
        3U,
        /** @brief Siul2 request type*/
        SIUL2_ICU_IRQ,
        /** @brief Siul2 Edge type*/
        SIUL2_ICU_RISING_EDGE,
        /** @brief Callback Pointer */
        NULL_PTR,
        /** @brief Notification function */
        &Usr_Btn_Callback,
          /** @brief Callback Param1*/
        16U
    }
};

/*
*  @brief    BOARD_InitPeripherals SIUL2 Instance Configuration
*/
const Siul2_Icu_Ip_InstanceConfigType Siul2_Icu_Ip_0_InstanceConfig_PB_BOARD_InitPeripherals =
{
    /** @brief Interrupt Filter Clock Prescaler */
    (uint8)2U,
    /** @brief Interrupt Filter Clock Alternate Prescaler  */
    (uint8)0U
};

/*
*  @brief    BOARD_InitPeripherals Default SIUL2 IP Configuration
*/
const Siul2_Icu_Ip_ConfigType Siul2_Icu_Ip_0_Config_PB_BOARD_InitPeripherals =
{
    /** @brief Number of Siul2 channels in the Icu configuration */
    (uint8)1U,
    /** @brief The Siul2 instance configuration */
    &Siul2_Icu_Ip_0_InstanceConfig_PB_BOARD_InitPeripherals,
    /** @brief Pointer to the array of Siul2 channel configurations */
    &Siul2_Icu_Ip_0_ChannelConfig_PB_BOARD_InitPeripherals
};

 

4. What I want.

I would like a simple program to change the led on and off. with an simple interrupt. I also have version 3.4/3.5 and 3.6 of the S32DS, because the HVBMS is on an S32k357 and the examples are on version 3.5 on the IDE.

 

0 Kudos
Reply
1 Reply

170 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

Thank you so much for your interest in our products and for using our community.

I suppose that you are using the examples provided in S32K344 Whiteboard Example Project.

Additionally you could refer to the example project for S32K344 that are included in the RTD:

2025-02-04_12-59-44.png

Hope it helps you.

Have a nice day!

0 Kudos
Reply