![]() |
Synergy Software Package User's Manual
|
The External IRQ HAL module provides an API for configuring and using external IRQ pins on Synergy MCUs. The External IRQ HAL module uses the Interrupt Controller Unit (ICU) of the Synergy MCU.
The following hardware features are, or are not, supported by SSP for ICU.
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Peripheral function interrupts | External pin interrupts | DTC and DMAC control | Interrupt sources for NVIC | Non-maskable interrupts (see notes) | Return from low power- mode (see notes) |
|---|---|---|---|---|---|---|
| S124 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S128 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S1JA | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A6 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A7 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S5D3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S5D5 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S5D9 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S7G2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Notes: ⎯ The ICU module in SSP (r_icu) handles only external pin interrupts and not the other features above. ⎯ Peripheral function interrupts are controlled by BSPs for each MCU and each peripheral driver modules in SSP. ⎯ DTC or DMA control is handled by DTC or DMAC module in SSP (r_dtc or r_dmac). ⎯ Non-maskable interrupts supported in SSP are IWDT Underflow, WDT Underflow and Voltage Monitor Interrupts. Those NMIs are controlled by IWDT, WDT or LVD modules (r_iwdt, r_wdt, or r_lvd), respectively. ⎯ LVD module (r_lvd) supports the Wake Up Interrupt Enable setting. For low power mode details, see the LPM section.
| MCU Group | RPEST | RECCST | BUSSST | BUSMST | SPEST |
|---|---|---|---|---|---|
| S124 | ⌧ | N/A | N/A | N/A | N/A |
| S128 | ⌧ | N/A | N/A | N/A | N/A |
| S1JA | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S3A1 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S3A3 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S3A6 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S3A7 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S5D3 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S5D5 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S5D9 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| S7G2 | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
The External IRQ HAL module defines APIs for opening, closing, and waiting for interrupt events from external pins. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
External IRQ HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_external_irq.p_api->open(g_external_irq.p_ctrl, g_external_irq.p_cfg)Open instance and initialize. |
| enable | g_external_irq.p_api->enable(g_external_irq.p_ctrl)Enable callback when IRQ occurs. |
| disable | g_external_irq.p_api->disable(g_external_irq.p_ctrl)Disable callback when IRQ occurs. |
| triggerSet | g_external_irq.p_api->triggerSet(g_external_irq.p_ctrl, trigger)Set trigger. |
| filterEnable | g_external_irq.p_api->filterEnable(g_external_irq.p_ctrl)Enable noise filter. |
| filterDisable | g_external_irq.p_api->filterDisable(g_external_irq.p_ctrl)Disable noise filter. |
| close | g_external_irq.p_api->close(g_external_irq.p_ctrl);Close instance. |
| versionGet | g_external_irq.p_api->wait(&version);Retrieve the API version with the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | Function successful. |
| SSP_ERR_ASSERTION | Assertion error. |
| SSP_ERR_INVALID_ARGUMENT | Callback is not NULL but ISR is not enabled. |
| SSP_ERR_IN_USE | Device in use. |
| SSP_ERR_NOT_OPEN | Device unopened. |
The External IRQ HAL module provides a set of API functions for controlling external interrupts. Interrupts can be triggered on rising edge, falling edge, both edges or low level of the input signal on the external IRQ pin. A digital-filtering function can be enabled to eliminate some noise on the input signal. A user-callback function is supported and is triggered each time an IRQ event occurs.
To trigger a transfer of data using the DMAC or DTC peripheral when the configured external IRQ event occurs, configure the DMAC or DTC transfer with the activation source set to ELC_EVENT_PORTn_IRQ (where n is the IRQ channel number.)
Other peripherals can be triggered to start from an external interrupt using the Event Link Controller (ELC.) Refer to the SSP User Manual User Guide for the ELC HAL module for more information.
This section describes how to include the External IRQ HAL Module in an application using the SSP configurator.
To add the External IRQ Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the External IRQ Driver is g_icu0. This name can be changed in the associated Properties window.)
External IRQ HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| r_icu0 External IRQ Driver on r_icu | Threads | New Stack> Driver> Input> External IRQ Driver on r_icu |
When the External IRQ Driver on r_icu is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The External IRQ HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the External IRQ HAL Module on r_icu
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Parameter checking setting enables or disables the addition of parameter checking code. |
| Name | g_external_irq0 | Module name. |
| Channel | 0 | Specifies the hardware IRQ channel used. |
| Trigger | Falling, Rising, Both Edges, Low Level Default: Rising | Selection for trigger event mode |
| Digital Filtering | Enabled, Disabled Default: Disabled | Digital filter enable/disable. |
| Digital Filtering Sample Clock (Only valid when Digital Filtering is Enabled) | PCLK/1, PLCK/8, PLCK/32, PCLK/64 Default: PCKL/64 | Sets noise filter sampling period. |
| Interrupt enabled after initialization | True, False Default: True | Determines if the interrupt is enabled immediately after initialization. |
| Callback | NULL | A user callback function can be registered in external_irq_api_t::open. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the IRQn triggers. Warning: Since the callback is called from an ISR, care should be taken not to use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
| Pin Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Priority 12 | Interrupt priority selection. |
The IRQ peripheral module does not require any specific clock settings.
The External IRQ peripheral module uses pins on the MCU to communicate to external devices. I/O pins must be selected and configured as required by the external device. The following table illustrates the method for selecting the pins within the SSP configuration window and the subsequent table illustrates an example selection for the IRQ pins.
Pin Selection for the External IRQ HAL Module on r_icu
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| IRQ | Pins | Select Peripherals> Input: IRQ> IRQ0 |
Pin Configuration Settings for the External IRQ HAL Module on r_icu
| Property | Value | Description |
|---|---|---|
| Operation Mode | Disabled, Enabled Default: Disabled | Select Enabled to enable interrupts. |
| NMI | None, P200 Default: None | Non-maskable interrupt Pin. |
| IRQ00:14 | None, Pnn, Pmm Default: None | Interrupt request Pin. |
The typical steps in using the External IRQ HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: