AnsweredAssumed Answered

Possible bug in MCUXPresso SDK 2.2 MKW41Z

Question asked by Gerardo Catena on Mar 22, 2018
Latest reply on Mar 29, 2018 by Gerardo Rodríguez

Hi,

I'm playing around the BLE and trying to get the battery voltage value from the DCDC with a connectivity software example. The example I'm using is the heart rate sensor but the problem should be the same in the others.

I have configured my board in DCDC buck mode. Indeed during the hardware_init it correctly executes the Board_DCDCInit and then the  DCDC_Init because in the app_preinclude.h is correctly enabled the DCDC through gDCDC_Enabled_d macro.

The problem arises during the function BleApp_Init which in turn call BOARD_InitAdc. The issue is in the latter because I expect it should be skipped. The body of the BOARD_InitAds is the following:
#if (gDCDC_Enabled_d == 0) || ((gDCDC_Enabled_d==1) && (APP_DCDC_MODE==gDCDC_Mode_Bypass_c))
      ...

      ...
#endif

the first part of the #if is ok, but I guess the second isn't because in app_preinclude APP_DCDC_MODE is a macro initialized with the enum gDCDC_Mode_Buck_c. I suppose that at preprocessor stage the #if statement will be translated as

 

#if (1==0) || ((  1==1) &&( gDCDC_Mode_Buck_c == gDCDC_Mode_Bypass_c))
and then as
#if (1==0) || ((1==1) && (0==0))
because the preprocessor isn't aware about variable and enum declaration, it just applies a textual substitution and a best-try evaluation. This is why, I think the body of the #if isn't skypped. My patch is just to assign 1 to the APP_DCDC_MODE macro instead of gDCDC_Mode_Buck_c.

 

 

Thanks

G.

Outcomes