The event link controller (ELC) uses the event requests generated by various peripheral modules as source signals to connect (link) them to different modules, allowing direct cooperation between the modules without central processing unit (CPU) intervention. The conceptual diagram below illustrates a potential setup where a pin input triggers a timer which later triggers an ADC conversion. These tasks would be automatically handled without the need for polling or interrupt management.
In essence, the ELC is an array of multiplexers to route a wide variety of interrupt signals to a subset of peripheral functions. Events are linked by setting the multiplexer for the desired function to the desired signal (through R_ELC_LinkSet). The diagram below illustrates one peripheral output of the ELC. In this example, a conversion start is triggered for ADC when the GPT00 counter overflows:
To manually link an event to a peripheral at runtime perform the following steps:
To disable the event, either use R_ELC_LinkBreak to clear the link for a specific event.
This module can be added to the Stacks tab via New Stack > System > Event Link Controller (r_elc).
Below is a basic example of minimal use of event linking in an application.
{
.
link[ELC_PERIPHERAL_GPT0_ACT0] = ELC_EVENT_SW_EVENT_0,
.link[ELC_PERIPHERAL_GPT0_ACT1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT4] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT5] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT6] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT0_ACT7] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT4] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT5] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT6] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GPT1_ACT7] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ADC0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_TSU0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_TSU1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_INPORTGR1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_INPORTGR0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_SINGLEPORT0] = ELC_EVENT_GPT_U0_GPT_ELCOVF_0,
.link[ELC_PERIPHERAL_SINGLEPORT1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_SINGLEPORT2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_SINGLEPORT3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_OUTPORTGR0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_OUTPORTGR1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH0_TGR0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH0_TGR1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH0_TGR2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH0_TGR3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH1_TGR0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH1_TGR1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH1_TGR2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_GBETH1_TGR3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC0] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC1] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC2] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC3] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC4] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC5] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC6] = ELC_EVENT_NONE,
.link[ELC_PERIPHERAL_ICU_DMAC7] = ELC_EVENT_NONE
};
void elc_basic_example (void)
{
handle_error(err);
err =
R_ELC_LinkSet(&g_elc_ctrl, ELC_PERIPHERAL_ADC0, ELC_EVENT_GPT_U0_GPT_ELCOVF_0);
handle_error(err);
}