Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
I'd like to generate an IRQ by a falling edge on RTC_XTAL1. For this I can use ERU0, 1B1.
Can someone tell me how to configurate the MCU for this purpose?
Im using an XMC4800F144.
0 Likes
1 Reply
DRubeša
Employee
Employee
First solution authored First like received
Hi,

unfortunately, I don´t have a complete working solution but I guess it´s better to show you how it could be realized. Maybe you also notice some small detail that I missed.

#include "xmc_scu.h"
#include "xmc_gpio.h"
#include "xmc_eru.h"

const XMC_ERU_ETL_CONFIG_t eru_etl_config =
{
.input_b = ERU0_ETL1_INPUTB_SCU_HIB_SR1,
.enable_output_trigger = 1,
.output_trigger_channel = XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL1,
.source = XMC_ERU_ETL_SOURCE_B,
.status_flag_mode = XMC_ERU_ETL_STATUS_FLAG_MODE_SWCTRL,
.edge_detection = XMC_ERU_ETL_EDGE_DETECTION_FALLING
};

const XMC_ERU_OGU_CONFIG_t eru_ogu_config =
{
.peripheral_trigger = 0U, /* OGU input peripheral trigger */
.enable_pattern_detection = false, /* Enables generation of pattern match event */
.service_request = XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER, /* Interrupt gating signal */
.pattern_detection_input = 0U
};

void IRQ_Hdlr_2 (void)
{
uint8_t index;

index = 0; // used just to set the breakpoint, unfortunately this point in code is not reached
}

int main(void)
{
XMC_ERU_ETL_Init(XMC_ERU0, 1, &eru_etl_config);
XMC_ERU_OGU_Init(XMC_ERU0, 1, &eru_ogu_config);

XMC_SCU_HIB_RTCCLKSRC_t currentStdbyClock;

if (XMC_SCU_HIB_IsHibernateDomainEnabled() == false)
{
XMC_SCU_HIB_EnableHibernateDomain();
}

XMC_SCU_CLOCK_EnableLowPowerOscillator();

// this part is added just for testing, enabling low power EXTERNAL oscillator should be sufficient
XMC_SCU_HIB_SetStandbyClockSource(XMC_SCU_HIB_STDBYCLKSRC_OSCULP);
XMC_SCU_HIB_SetRtcClockSource(XMC_SCU_HIB_RTCCLKSRC_ULP);

currentStdbyClock = XMC_SCU_HIB_GetStdbyClockSource();

NVIC_SetPriority((IRQn_Type)2, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 63, 0));
NVIC_EnableIRQ((IRQn_Type)2);

/* Loop forever */
while (1)
{

}
}


The code doesn´t reach interrupt routine and there is not even status flag set which will signify that falling edge is detected. I´ve tried also with rising and both edges and it doesn´t seem to have an impact. When I tried the use some of the buttons with similar code (different board, different input pin, different ERU module and different interrupt service routine) I was successful, which may me lead that maybe the voltage level transition on a RTC_XTAL1 pin are not sufficient to trigger ERU module edge detection. But again, maybe this is working fine but there are some issues with initialization which currently I don´t see. So try it by yourself and see if you see some issues with the code.

Best regards,
Deni
0 Likes