cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in STM32L0 TSC library

JGrci
Associate

I would like to report a bug in HAL TSC library for the stm32L0 series of microcontrollers.

The bug is in the stm32l0xx_hal_tsc.h header file in the  __HAL_TSC_GET_GROUP_STATUS macro.

This is the current version of the macro (buggy version):

#define __HAL_TSC_GET_GROUP_STATUS(__HANDLE__, __GX_INDEX__) \

((((__HANDLE__)->Instance->IOGCSR & (uint32_t)(1UL << (((__GX_INDEX__) & (uint32_t)TSC_NB_OF_GROUPS) + 16UL))) == (uint32_t)(1UL << (((__GX_INDEX__) & (uint32_t)TSC_NB_OF_GROUPS) + 16UL))) ? TSC_GROUP_COMPLETED : TSC_GROUP_ONGOING)

This macro always returns the state of the Group 1, regardless of the __GX_INDEX__.

The correct version of the macro should be:

#define __HAL_TSC_GET_GROUP_STATUS(__HANDLE__, __GX_INDEX__) \

((((__HANDLE__)->Instance->IOGCSR & (uint32_t)(1UL << (((__GX_INDEX__)) + 16UL))) == (uint32_t)(1UL << (((__GX_INDEX__)) + 16UL))) ? TSC_GROUP_COMPLETED : TSC_GROUP_ONGOING)

In short eliminate the "& (uint32_t)TSC_NB_OF_GROUPS)" code.

I have also fond that this (correct) version is in the CubeMX STM32F3 library and this library works OK.

Hope this will be helpful to others !

2 REPLIES 2
Imen.D
ST Employee

Hello,

I will check this reported issue and come back to you with update.

Thanks for your contribution.

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hello,

This issue is confirmed and will be fixed in coming release of Cube firmware package.

Kind Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen