Potential ERU Init issue

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

cross mob
andriy
Level 1
Level 1
5 replies posted 5 sign-ins First reply posted

Hello,

There is a problem in the XMC_ERU_ETL_Init() function that can cause issues.

The function call uses the union XMC_ERU_ETL_CONFIG_t

union
{
uint32_t input;
struct
{
uint32_t input_a: 2;
uint32_t input_b: 2;
uint32_t : 28;
};

....

}

The function call XMC_ERU_ETL_Init()  assumes that the user has zeroed out 28 most significant bits in the input field. This may not be the case if the config is on the stack, i.e.

XMC_ERU_ETL_CONFIG_t etl_config;

etl_config.input_a = 1;

etl_config.input_b = 1;

XMC_ERU_ETL_Init(..,  .., &etl_config);

The above call will randomly overwrite the configuration in the EXISEL register... causing issues in previously set-up ERUs.

To fix this the user must explicitly zero initialize the config. So the following code will work fine:

XMC_ERU_ETL_CONFIG_t etl_config = { 0 };

etl_config.input_a = 1;

etl_config.input_b = 1;

XMC_ERU_ETL_Init(..,  .., &etl_config);

This is easy to miss and can cause hard to troubleshoot problems.

I suggest that the XMC_ERU_ETL_Init() call is modified to explicitly zero out the 28 most significant bits before assignment to the EXISEL register.

Andriy

 

 

 

 

 

 

 

 

0 Likes
2 Replies
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @andriy ,

Can you please mention the device, that you are using? I will try to check at my end first to understand the issue.

Best Regards,

Aashita

0 Likes
andriy
Level 1
Level 1
5 replies posted 5 sign-ins First reply posted

Thanks, I'm using the XMC4700 Relax kit.

0 Likes