2019-03-07 02:01 AM
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 !
2019-03-08 08:30 AM
Hello,
I will check this reported issue and come back to you with update.
Thanks for your contribution.
Kind Regards,
Imen
2019-03-12 01:15 AM
Hello,
This issue is confirmed and will be fixed in coming release of Cube firmware package.
Kind Regards,
Imen.