S32K312 IO中断(Siul2_Icu)

发布时间:2024年01月24日

本文主要描述S32K312的Siul2_Icu方式IO中断配置和测试代码编写,以PTB9引脚作为IO输入中断为例。

1、Pins配置

1)选择Pins配置

2)选中IO中断的引脚

3)选择eirq的方式

4)配置输入的属性

2、外设配置

1)增加组件Siul2_Icu、IntCtrl_IP、Siul2_Port

?2)配置Siul2_Icu

3)配置IntCtrl_Ip

配置完成后,更新源代码。

3、编辑代码

/*==================================================================================================
*   Project              : RTD AUTOSAR 4.4
*   Platform             : CORTEXM
*   Peripheral           : S32K3XX
*   Dependencies         : none
*
*   Autosar Version      : 4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 2.0.1
*   Build Version        : S32K3_RTD_2_0_1_D2207_ASR_REL_4_4_REV_0000_20220707
*
*   (c) Copyright 2020 - 2021 NXP Semiconductors
*   All Rights Reserved.
*
*   NXP Confidential. This software is owned or controlled by NXP and may only be
*   used strictly in accordance with the applicable license terms. By expressly
*   accepting such terms or by downloading, installing, activating and/or otherwise
*   using the software, you are agreeing that you have read, and that you agree to
*   comply with and are bound by, such license terms. If you do not agree to be
*   bound by the applicable license terms, then you may not retain, install,
*   activate or otherwise use the software.
==================================================================================================*/

/**
*   @file main.c
*
*   @addtogroup main_module main module documentation
*   @{
*/

/* Including necessary configuration files. */
#include "Mcal.h"
#include "Clock_Ip.h"
#include "IntCtrl_Ip.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Icu_Ip.h"

volatile int exit_code = 0;
/* User includes */
#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.h"

uint32_t edge_cnt = 0;
void User_EdgeDetect0(void)
{
    /* increment IRQ counter */
	SEGGER_RTT_printf(0,"User_EdgeDetect0() edge_cnt=%d\n", edge_cnt++);
}
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
int main(void)
{
    /* Write your code here */
	SEGGER_RTT_printf(0,"program start\n");
	/* Initial Clock */
	Clock_Ip_InitClock(&Clock_Ip_aClockConfig[0]);
	/*Initial Pin */
	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
	/*Initial ISR*/
	IntCtrl_Ip_Init(&IntCtrlConfig_0);
	IntCtrl_Ip_ConfigIrqRouting(&intRouteConfig);

	IntCtrl_Ip_InstallHandler(SIUL_1_IRQn, &SIUL2_EXT_IRQ_8_15_ISR, NULL_PTR);
	IntCtrl_Ip_EnableIrq(SIUL_1_IRQn);

	/* Initialize the Icu driver */
	Siul2_Icu_Ip_Init(0, &Siul2_Icu_Ip_0_Config_PB_BOARD_InitPeripherals);

	Siul2_Icu_Ip_EnableInterrupt(0, 15);
	Siul2_Icu_Ip_EnableNotification(0, 15);
	SEGGER_RTT_printf(0,"program loop\n");
    for(;;)
    {
        if(exit_code != 0)
        {
            break;
        }
    }
    return exit_code;
}

/** @} */

其中,配置IntCtrl_Ip_InstallHandler中断时,参考下图。15引脚?属于SIUL_1_IRQn。

最后,运行代码的效果

?

文章来源:https://blog.csdn.net/lnniyunlong99/article/details/135817737
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。