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

cross mob
Not applicable
We have a project for an XMC4504-F100x512 which includes 2 PWM inputs that we are measuring using CCU4 channels and the CAP001 app. When looking at the CAP001_Init function, I noticed that it generated the same block of init code twice. It looks like it is trying to initialize both handles (CAP001_Handle0/1), but both blocks of code reference the same handle. The CAP001_Deinit function takes a handle as a parameter and just operates on that channel which is a much more desirable interface. With the current Init function structure, I can't just enable the channel I want without disabling the one I don't want.

I tried to attach the CAP001.c file, but it gave me an error about the file type. Instead I copy/pasted the init function below.


void CAP001_Init(void)
{
status_t Error = (uint32_t)CAP001_OPER_NOT_ALLOWED_ERROR;

CCU4GLOBAL_Init();

Error = CAP001_lInit((CAP001_HandleType*) &CAP001_Handle0);
/* Start the app if "Start after initialization" is checked */
if(Error == DAVEApp_SUCCESS)
{
if (CAP001_Handle0.StartControl == (uint8_t)SET)
{
Error = CAP001_Start((CAP001_HandleType*) &CAP001_Handle0);
}
}

Error = CAP001_lInit((CAP001_HandleType*) &CAP001_Handle0);
/* Start the app if "Start after initialization" is checked */
if(Error == DAVEApp_SUCCESS)
{
if (CAP001_Handle0.StartControl == (uint8_t)SET)
{
Error = CAP001_Start((CAP001_HandleType*) &CAP001_Handle0);
}
}
}
0 Likes
2 Replies
Not applicable
Thinking about this a little more, you should really change the Init function to take a handle like the Deinit function. Otherwise, you can't disable and then re-enable a channel without effecting all of the other channels which is a major pain.
0 Likes
Georg_Huba
Employee
Employee
We can confirm that this is a problem in the CAP001 App. When using more than one instance of the CAP001 App the initialization code is not correct. We will provide a fix in a new version of CAP001 App in one of the next releases.
0 Likes