Possible bug in MCUXPresso SDK 2.2 MKW41Z

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possible bug in MCUXPresso SDK 2.2 MKW41Z

652 Views
gerardocatena
Contributor II

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.

Labels (1)
0 Kudos
1 Reply

507 Views
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Gerardo Catena,

You are totally right, the enum values are not recognized by the preprocessor and the undefined identifiers are treated as 0, so that macro always evaluates as true. I will report this to the SW team, so hopefully this gets fixed in future releases.

The impact of this, is that the ADC will be reinitialized with the clock source set to the Asynchronous Clock, instead of the bus clock set inside DCDC_Init().

Best regards,

0 Kudos