STMicroelectronics / STM32CubeG0

STM32Cube MCU Full Package for the STM32G0 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
164 stars 75 forks source link

cast conversion issue when _LL_RTC_CONVERT_BCD2BIN macro is used #24

Closed jealcuna closed 1 year ago

jealcuna commented 2 years ago

I am using stm32cube ide 1.7.0 and when I use the macro _LL_RTC_CONVERT_BCD2BIN a warning rise. I have wconversion warning flag enable, also, when I call the macro y use a uint8_t type data. I have -o2 optimization.

image

In the picture attached VALUE is replaced by a uint8_t variable with a valir bcd number.

This is the code which is calling the macro:

ptm.tm_hour = (int)LL_RTC_CONVERT_BCD2BIN((uint8_t)LL_RTC_GET_HOUR(time_bcd));

jealcuna commented 2 years ago

A workaround for this is replace the line with:

define LL_RTC_CONVERT_BCD2BIN(VALUE) (uint8_t)((((uint8_t)((VALUE) & (uint8_t)0xF0) >> (uint8_t)0x04) * (uint8_t)10) + ((VALUE__) & (uint8_t)0x0F))

ALABSTM commented 2 years ago

Hi @jealcuna,

Thank you for this report. We will get back to you with a feedback as soon as possible. Please excuse the delay it may take us sometimes to reply. Thank you for your comprehension.

With regards,

ALABSTM commented 2 years ago

Hi @jealcuna,

I hope you are fine. We tried to reproduce the problem you reported, with no success. Below the environment configuration used:

Would you mind precising the types of variables time_bcd and ptm.tm_hour used in your code?

Thanks,

ALABSTM commented 1 year ago

Hi @jealcuna,

I hope you are doing well. As there has been no activity on this thread since a while and as we could not reproduce the issue you reported, please allow me to close this issue. Thank you for your comprehension.

With regards,