STM32CubeG0 icon indicating copy to clipboard operation
STM32CubeG0 copied to clipboard

cast conversion issue when _LL_RTC_CONVERT_BCD2BIN macro is used

Open jealcuna opened this issue 4 years ago • 3 comments

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 avatar Nov 24 '21 18:11 jealcuna

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))

jealcuna avatar Nov 25 '21 01:11 jealcuna

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 avatar Jan 30 '22 08:01 ALABSTM

Hi @jealcuna,

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

  • STM32CubeG0 v1.6.1
  • Cube IDE v1.9.0
  • Optimization level -O2
  • Compilation flags -Wall and -Wconversion enabled

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

Thanks,

ALABSTM avatar Aug 05 '22 11:08 ALABSTM

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,

ALABSTM avatar Apr 10 '23 11:04 ALABSTM