[KW36] MCU on VLPR with BLPE or BLPI clocking modes

Document created by Luis Antonio Burgos Lopez Employee on Oct 26, 2018
Version 1Show Document
  • View in full screen mode

This post explains the implementation to operate the KW36 MCU on VLPR when the clocking mode is BLPE or BLPI. It's also included the explanation on how to configure clocks for BLPE and BLPI modes.

 

For this example, the beacon demo from the wireless examples of the FRDM-KW36 is used. FRDM-KW36 SDK can be downloaded from MCUXpresso webpage.

 

A recommended option to configure clock modes is "Config Tools" from MCUXpresso. Config Tools is embedded to MCUXpresso IDE, or you can download Config Tools from this LINK if you are using other supported IDE for this tool. MCUXpresso IDE is used in this example.

 

Configure BLPE or BLPI clocking modes

 

Select your proyect on MCUXpresso IDE, then open the clocks configuration window from Config Tools by clicking the arrow next to Config Tools icon from your MCUXpresso IDE, and then select "Open Clocks" as shown in Figure 1.

 

Figure 1. Open Clocks from Config Tools using MCUXpresso IDE.

 

A clocks diagram window will be opened. To configure the clock modes just select your option "BLPI" or "BLPE" on MCG Mode as shown in Figure 2. Clock will be automatically configured.

 

Figure 2. MCG Mode selection.

 

Now let's configure the appropiate clocks for Core clock and Bus clock to run in VLPR.

Figure 3 taken from KW36 Reference Manual shows achievables frequencies when MCU is on VLPR. 

 

Figure 3. VLPR clocks.

 

Core clock should be 4MHz for BLPE and BLPI clocking modes, and Bus clock should be 1MHz for BLPE and 800kHz for BLPI. 

Figure 4 shows clocks distribution for BLPE and Figure 5 for BLPI to operate with discussed frequencies.

 

Figure 4. Clock distribution - VLPR and BLPE.

 

Figure 5. Clock distribution - VLPR and BLPI.

Press "Update Project" (Figure 6) to apply your new clock configuration to your firmware, then change perspective to "Develop" icon on right corner up to go to your project (See Figure 7). Compile your project to apply the changes.

 

Figure 6. Update Project button.

 

Figure 7. Develop button.

 

 

At this point your project is ready to work with BLPE or BLPI clocks modes. Now, let's configure MCU to go to VLPR power mode.

 

Configure VLPR mode

 

VLPR mode can be configured using Config Tools too, but you may have an error trying to configure it when BLPE mode, this is because CLKDIV1 register cannot be written when the device is on VLPR mode. For this example, let's configure MCU into VLPR mode by firmware.

 

Follow next steps to configure KW36 into VLPR power mode:

 

1. Configure RF Ref Oscillator to operate in VLPR mode.

 

By default, the RF Ref Osc it's configured to operate into RUN mode. To change it to operate on VLPR mode just change the bits RF_OSC_EN from Radio System Control from 1 (RUN) to 7 (VLPR). Figure 8 taken from KW36 Reference Manual shows RF_OSC_EN value options from Radio System Control. 

 

Figure 8. RF_OSC_EN bits from Radio System Control register.

 

Go to clock_config.c file in your MCUXpresso project and search for "BOARD_RfOscInit" function. Change the code line as shown in Figure 9 to configure RF Ref Osc to work into VLPR mode. You may see a window asking if you want to make writable the read-only file, click Yes.

 

Figure 9. Code line to configure RF Ref Osc to work into VLPR mode

 

Be aware that code line shown in Figure 9 may change with updates done in clocks using Config Tools.

Note

 

2. Configure DCDC in continuous mode.

 

 

According to KW36 Reference Manual, the use of BLPE in VLPR mode is only feasible when the DCDC is configured for continuous mode.

 

First, let's define gDCDC_Enabled_d flag to 1 on preprocesor. With this implementation, the use of DCDC_Init function will be enabled, and it's where we going to add the code line to enable continuous mode.

 

Right click on your project, select Properties, go to Settings under C/C++ Build, then Preprocessor under MCU C Compiler (Figure 10).

 

Figure 10. MCUXpresso Preprocessor

 

Click on add button from Defined symbols, write gDCDC_Enabled_d=1 and click OK to finish (Figure 11). 

Re-compile your project.

 

Figure 11. MCUXpresso Defined symbols

 

 

Now let's set VLPR_VLPW_CONFIG_DCDC_HP bits to 1 from DCDC_REG0 register. Figure 12 was taken from KW36 Reference Manual.

 

 

 

Figure 12. VLPR_VLPW_CONFIG_DCDC_HP values.

 

Go to DCDC_Init  function and add the next code line to enable continuous mode on DCDC:

  • DCDC->REG0 |= DCDC_REG0_VLPR_VLPW_CONFIG_DCDC_HP_MASK;

 

Figure 13 shows the previous code line implemented in firmware project inside of DCDC_Init function.

 

Figure 13. Continuous mode for DCDC enabled.

 

3. Configure MCU into VLPR mode

 

To finish, let's write the code to configure MCU into VLPR power mode.

 

Copy and paste next code just after doing implementation described on step 1 and 2:

 

#if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI)
SMC_SetPowerModeVlpr(SMC, false);
#else
SMC_SetPowerModeVlpr(SMC);
#endif

 

while (kSMC_PowerStateVlpr != SMC_GetPowerModeState(SMC))
{
}

 

It may be needed to add the SMC library:

#include "fsl_smc.h"

 

The code is configuring MCU into VLPR mode with bits RUNM from SMC_PMCTRL register (Figure 14) and then check if it was correctly configured by reading status bits PMSTAT from SMC_PMSTAT register (Figure 15)

 

 

Figure 14. RUNM bits from SMC_PMCTRL register.

 

 

Figure 15. PMSTAT bits from  SMC_PMSTAT register.

 

KW36 is ready to operate and BLPE or BLPI clocking modes with VLPR power mode.

Attachments

    Outcomes