Pin interrupt on XMC1 (via XMC Lib) not working

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

cross mob
WoS
Employee
Employee
First solution authored
Hi all,

got another issue. For completeness: I am using the xmc 2go board for this experiments.

I'd like to call a handler (toggling a LED) each time the pin P2_11 receives a falling edge.
So not too complicated for the beginning 😉

P2.11 is beside GND, so easy to use a jumper for stimulation of the pulse.

I checked the XMC1100 manual about the ERU and examples I found in the lib package about handling pin interrupts.
So I set up something similar I expected to work - but it doesn't yet. Also found no other clues in the forum.

Here the excerpt of the program:


/* example does not work ... */

#include
#include

void ERU0_0_IRQHandler(void)
{
XMC_GPIO_ToggleOutput(P1_0);
}


int main(void) {
/* output for indication of handler calls */

const XMC_GPIO_CONFIG_t p1_x_conf = {
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW
};
XMC_GPIO_Init(P1_0,&p1_x_conf); /* LED 1 */
XMC_GPIO_Init(P1_1,&p1_x_conf); /* LED 2 */

/* P2.11 is ERU0.2B1 which requires the path ERS2 -> ETL2
* we then send this to OGU0 triggering the interrupt */

const XMC_ERU_ETL_CONFIG_t p2_11_int_event_generator_config =
{
.input = XMC_ERU_ETL_INPUT_B1, /* 2B1 */
.source = XMC_ERU_ETL_SOURCE_B,
.edge_detection = XMC_ERU_ETL_EDGE_DETECTION_FALLING,
.status_flag_mode = XMC_ERU_ETL_STATUS_FLAG_MODE_HWCTRL,
.enable_output_trigger = true,
.output_trigger_channel = XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL0 /* OGU0 */
};
XMC_ERU_ETL_Init(ERU0_ETL2, &p2_11_int_event_generator_config);
const XMC_ERU_OGU_CONFIG_t p2_11_event_detection_config =
{
.service_request = XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER
};
XMC_ERU_OGU_Init(ERU0_OGU0, &p2_11_event_detection_config);

/* pin configuration of /INT input */

const XMC_GPIO_CONFIG_t p2_11_conf = {
.mode = XMC_GPIO_MODE_INPUT_PULL_UP,
.input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD
};
XMC_GPIO_Init(P2_11,&p2_11_conf); /* /INT */

NVIC_SetPriority(ERU0_0_IRQn, 3U);
NVIC_EnableIRQ(ERU0_0_IRQn); /* now it is (should be) hot... */

while(1) {
if (XMC_GPIO_GetInput(P2_11)) {
XMC_GPIO_SetOutputLow(P1_1);
} else {
XMC_GPIO_SetOutputHigh(P1_1);
}
};
}


The LED2 goes on when the pin gets zero, so the GPIO should be set correctly. But the other LED does not toggle.
I went over and over again on the ERU config but can't see what's wrong - hopefully one can help me out here...
I also saw that the NVIC pending bit is not set, so I assume the event does not reach the NVIC at all.

Thanks a lot,

/WoS
0 Likes
2 Replies
WoS
Employee
Employee
First solution authored
I think I discovered an other bug in the XMC lib?

In my above example, EXS2B of ERU0/EXISEL should be set to one after calling "XMC_ERU_ETL_Init(ERU0_ETL2, &p2_11_int_event_generator_config)". So the register 0x40010600 should countain the value 0x00000400. I overlooked it during debugging, just saw it sets it to 0x00000100 instead (which enables wrongly 2A1).

When I set it manually (by using ".input = XMC_ERU_ETL_INPUT_B1<<2," in the const structure), the example works...
0 Likes
chismo
Employee
Employee
First like received
Hello,

The data type "input" by default selects the A set of inputs.
To select a B input, the data type "input_b" has to be used instead.
I think your code will work with the following:

.input_b = XMC_ERU_ETL_INPUT_B1,

In general, I would suggest to always use the data types "input_a" and/or "input_b" for the ERU.

Regards,
Min Wei
0 Likes