In this use case, the EVENT module is configured for:
- Synchronous event path with rising edge detection on the input
- One user attached to the configured event channel
- No hardware event generator attached to the channel
This use case allocates an event channel. This channel is not connected to any hardware event generator, events are software triggered. One user is connected to the allocated and configured event channel.
Setup
Prerequisites
There are no special setup requirements for this use-case.
Code
Add to the main application source file, before any functions, according to the kit used:
- SAM D20 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU
- SAM D21 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU
- SAM R21 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU
- SAM D11 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC2_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC1_EVU
- SAM L21 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE
#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0
- SAM L22 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE
#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0
- SAM DA1 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU
- SAM C21 Xplained Pro:
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE
#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0
- SAM HA1G16A Xplained Pro
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0
#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU
Copy-paste the following setup code to your user application:
{
config.generator = CONF_EVENT_GENERATOR;
}
{
}
Create an event resource struct and add to user application (typically the start of main()
): Add to user application initialization (typically the start of main()
): configure_event_channel(&example_event);
configure_event_user(&example_event);
Workflow
- Create an event channel configuration struct, which can be filled out to adjust the configuration of a single event channel.
- Initialize the event channel configuration struct with the module's default values.
- Note
- This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
- Adjust the configuration struct to request that the channel is to be attached to the specified event generator, that rising edges of the event signal is to be detected on the channel, and that the synchronous event path is to be used.
config.generator = CONF_EVENT_GENERATOR;
- Allocate and configure the channel using the configuration structure.
- Note
- The existing configuration struct may be re-used, as long as any values that have been altered from the default settings are taken into account by the user application.
- Attach a user to the channel.
Use Case
Code
Copy-paste the following code to your user application:
Workflow
- Wait for the event channel to become ready to accept a new event trigger.
- Perform a software event trigger on the configured event channel.