SIUL2 external interrupt example project using S32K3 RTD without AUTOSAR

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

SIUL2 external interrupt example project using S32K3 RTD without AUTOSAR

SIUL2 external interrupt example project using S32K3 RTD without AUTOSAR

The S32K3 RTD 2.0.0 lacks SIUL2 external interrupt function. Siul2_Icu is part of Icu(Input Capture Unit), the main function of the example should have been: use the Icu and Dio drivers to toggle a LED on a push button. But it doesn't. So this document will show the step-by-step process to add 'SIUL2 external interrupt' function in Siul2_Port_Ip_Example_S32K344 using the S32K3xx RTD LLD(Low Level Driver) and the S32 Configuration Tools. This example is for the S32K3X4EVB-Q257, connected to a PC through USB (OpenSDA) connection.

Preparation

  1. Setup the software tools
    1. Install S32 Design Studio for S32 Platform
    2. Install the S32K1xx development package and the S32K1 RTD AUTOSAR 4.4. Both of these are required for the S32 Configuration Tools.

      S32K3 RTD AUTOSAR 4.4 Version 2.0.0.png

  2. Launch S32 Design Studio for S32 Platform

Procedure

1. Import Siul2_Port_Ip_Example_S32K344 example

File->New->S32DS Project from Example

Create Siul2_Port_Ip_Example_S32K344.png

It can be seen that in the Icu (Input Capture Unit Driver) folder of S32K3 RTD 2.0.0, there are only interrupt routines implemented by the Emios module for the time being, and external interrupt routines for the EIRQ pin of the Siul2 module does not exist. Here we import the Siul2_Port_Ip_Example_S32K344 routine, and add the Siul2_Icu part on this basis.

AN13435 ICU SIUL2.pngS32K3 real time driver COMPONENTS.png

 

2. Add push button and LED in Pins tool

Add the pins for user buttons (SW4 PTB26 SIUL2 eirq13) according to the S32K3X4EVB-Q257.

Pins Tool.pngS32K3X4EVB-Q172_SCH_RevA.png

 

3. Add IntCtrl_Ip component

Go to Peripherals tool. Here we can see that the ‘Siul2_Dio’ and ‘Siul2_Port’ components are already added.

Drivers default.png

From the Components view, click on ‘Add a new configuration component…’ button from the Drivers category. This will bring up a list of non-AUTOSAR components. Locate and then select the ‘IntCtrl_Ip’ component from the list and click OK.

IntCtrl_Ip step1.png

Option 1: Keep the default setting after add ‘IntCtrl_Ip’ component(Here we didn't change the settings of ‘IntCtrl_Ip’, nor use IntCtrl_Ip_Init and IntCtrl_Ip_ConfigIrqRouting API to enable interrupts and install handlers in IntCtrl_Ip).This routine only uses one interrupt, so we will call IntCtrl_Ip_InstallHandler and IntCtrl_Ip_EnableIrq those two APIs to install and enable the SIUL2 EIRQ13 IRQ separately.

IntCtrl_Ip step3.png

Option 2: User can enable many interrupts in the Interrupt Controller configuration(Note user can only add one interrupt controller configuration in the RTD); Meanwhile, it can set interrupt’s priority separately. The two APIs IntCtrl_Ip_Init and IntCtrl_Ip_ConfigIrqRouting can initialize these interrupts as a whole.

Interrupt Controller.png

The name of the Handler in the Generic Interrupt Settings tab needs to be the same as the name in peripheral_Ip_Irq.c of the corresponding peripheral. For example, this routine uses the PTB26 SIUL2 EIRQ13 external interrupt, which can be found in RTD/src/Siul2_Icu_Ip_Irq.c: ISR(SIUL2_EXT_IRQ_8_15_ISR)

Generic Interrupt Settings.png

According to the "Table 35" of S32K3XXRM reference manual, we can see the SIUL2 EIRQ13(PTB26) external interrupt used in this routine belongs to SIUL_1_IRQn and the Handler name SIUL2_EXT_IRQ_8_15_ISR.

Table 35. Interrupt source mapping to SIUL2 interrupt request output for 32 interrupt sources.png

 

4. Add Siul2_Icu component

Click on ‘Add a new configuration component…’ button from the Drivers category. Locate and then select the ‘Siul2_Icu’ component from the list and click OK.

Siul2_Icu step1.pngFigure 22. External interrupt pad diagram.png

Step 5 select SIUL2_0_IRQ_CH_13 because this routine selects the onboard SW4 PTB26 SIUL2 EIRQ13 external interrupt (the onboard SW5 PTB19 pin has no EIRQ external interrupt function, so I did not added here). Step 6 set DIRER0[EIREn] to enable this external interrupt pin.

Siul2_Icu IcuHwInterruptConfigList.png

Step 8 set the IFCPR[IFCP] filter clock prescaler. Step 10 input 13 for the Hardware channel due to we use SIUL2 EIRQ13. Step 11 set IFER0[IFEn] to enable the glitch filter for the external interrupt pin. Step 12 set IFMCRn[MAXCNT] to assign value to the external interrupt filter counter.

Siul2_Icu IcuSiul2.png

Step 14 select the IcuSiu2Channel_0 channel configured in the IcuSiul2 tab above. Step 15 select the ICU_RISING_EDGE according to the SW4 button circuit (press to generate a rising edge). Step 16 Because the SIUL2 EIRQ external interrupt is used in this routine, ICU_MODE_SIGNAL_EDGE_DETECT mode must be selected. Step 17 add the corresponding callback function name. That is, it corresponds to the notification after the SIUL2 EIRQ external interrupt pin captures the rising edge (the interrupt flag does not need to be cleared here, the driver has already been implemented it).

Siul2_Icu IcuChannels.png

 

5. Include the headers for the drivers used in the application

#include "Siul2_Icu_Ip.h"
#include "IntCtrl_Ip.h"

 

6. Add Siul2_Icu LLD APIs

Siul2_Icu_Ip_Init is used to initialize all Siul2_Icu channels generated by the S32 Configuration Tools (this routine only configures the channel SW4 PTB26 SIUL2 EIRQ13). Siul2_Icu_Ip_EnableInterrupt enable Siul2 IRQ interrupt for the specified channels. Siul2_Icu_Ip_EnableNotification enable callback function of Siul2 IRQ interrupt for the specified channels. This routine uses the SW4 button to trigger the PTB26 SIUL2 EIRQ13 external interrupt callback function SW4_eirq13_PTB26_Callback to flip the PTB18 D33 red LED.

Siul2_Icu API.png

 

7. Add IntCtrl LLD APIs

IntCtrl_Ip_InstallHandler installs the SIUL2_EXT_IRQ_8_15_ISR interrupt handler generated by the S32 Configuration Tools. IntCtrl_Ip_EnableIrq enables the corresponding interrupt. Why input SIUL_1_IRQn and SIUL2_EXT_IRQ_8_15_ISR has been explained at the end of "4. Adding the IntCtrl_Ip component" above.

IntCtrl_Ip API.png

References

- S32K3xx Pins and Clocks with RTD - Training
- AN13435: SDK/MCAL to Real-Time Drivers
- Integration Manual for S32K3 ICU Driver (RTD_ICU_IM.pdf)
- User Manual for S32K3 ICU Driver (RTD_ICU_UM.pdf)
- Integration Manual for S32K3 PLATFORM Driver (RTD_PLATFORM_IM.pdf)
- User Manual for S32K3 PLATFORM Driver (RTD_PLATFORM_UM.pdf)

Attachments
100% helpful (2/2)
Version history
Last update:
‎11-13-2022 05:49 AM
Updated by: