XMC Peripheral Library error?

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

cross mob
User10696
Level 4
Level 4
First solution authored
I think there is an error in the XMC Peripheral Libray for the FCE (Flexible CRC Engine). In the function XMC_FCE_CalculateCRC32() the data should be checked if it is word aligned, but in the code the length is check:
XMC_FCE_STATUS_t XMC_FCE_CalculateCRC32(const XMC_FCE_t *const engine,
const uint32_t *data,
uint32_t length,
uint32_t *result)
{
XMC_FCE_STATUS_t status = XMC_FCE_STATUS_OK;

XMC_ASSERT("XMC_FCE_CalculateCRC32: Wrong FCE kernel used", ((engine->kernel_ptr == XMC_FCE_CRC32_0) ||
(engine->kernel_ptr == XMC_FCE_CRC32_1)));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length field is empty", (length != 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length is not aligned", ((length & 0x03) == 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Buffer is not aligned", (((uint32_t)data % 4U) == 0));

/* Check if data and length are word aligned */
if (((length & 0x03U) != 0U) || (((uint32_t)length % 4U) != 0U))
{
status = XMC_FCE_STATUS_ERROR;
}
else
{
while (0UL != length)
{
engine->kernel_ptr->IR = *data;
data++;
length -= 4U;
}

*result = engine->kernel_ptr->CRC;
}

return status;
}
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Thanks for reporting.We will address it in the next release.

I think that there is no need for the data to be aligned.
The check only makes sense if the user has enabled the unalign access exception.
Otherwise the unalign access is allowed in CortexM4 with the associated performance penalties.


Regards,
Jesus
0 Likes
User10696
Level 4
Level 4
First solution authored
I am not sure if it is necessary, but the comment and the code do not seem to match.
0 Likes