This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0L2228: MSPM0L2228 – Clock Frequency Resets to 32 MHz When Running on Battery Only (Using BQ24072RGT)

Part Number: MSPM0L2228

Tool/software:

Dear TI Support Team,

I am working with the MSPM0L2228 microcontroller in a battery-powered application. The system uses the internal high-speed oscillator (HSOSC) as the main clock and an external 32.768 kHz crystal for low-frequency timing.

For battery charging, we are using the BQ24072RGT charger IC. The PG (Power Good) and CHG (Charge Status) pins are connected to the MCU GPIOs for monitoring the charging state.

We are seeing the following behavior:
- When the charger is connected and PG is low, the MCU runs at the expected configured frequency.
- When the charger is disconnected (PG goes high) and the system switches to battery-only power, the system frequency drops to 32 MHz — suggesting a fallback to the default HSOSC configuration.
- When the charger is reconnected, the MCU returns to the correct frequency configuration.

We are not intentionally modifying the clock configuration during power transitions. This leads us to believe that a voltage dip, brown-out, or internal reset may be causing the clock system to revert to defaults.

Could you please help clarify:
1. Under what conditions would the MSPM0L2228 revert to 32 MHz default HSOSC behavior?
2. Does the controller lose its clock configuration when switching from charger to battery?
3. What is the recommended approach to maintain or reinitialize the clock configuration in such scenarios?
4. Is it expected that PG/CHG or VDDS changes could trigger a reset or fallback behavior?

I can share my clock initialization code and schematic if needed. Your insights on maintaining clock stability during power transitions would be greatly appreciated.

Best regards,
ANKUSH

  • Hi Ankush,

    1) Could you please share your code and schematic?

    2) It sounds like the device is functioning at 32.768KHz when plugged in, but increases to 32MHz when unplugged. Is my understanding correct?

    3) Please clarify what the "expected configured frequency" is for each test condition (plugged in, unplugged, etc.)

    -Matthew

  • /*
     * Copyright (c) 2023, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ============ ti_msp_dl_config.c =============
     *  Configured MSPM0 DriverLib module definitions
     *
     *  DO NOT EDIT - This file is generated for the MSPM0L222X
     *  by the SysConfig tool.
     */
    
    #include "ti_msp_dl_config.h"
    
    /*
     *  ======== SYSCFG_DL_init ========
     *  Perform any initialization needed before using any board APIs
     */
    SYSCONFIG_WEAK void SYSCFG_DL_init(void)
    {
        SYSCFG_DL_initPower();
        SYSCFG_DL_GPIO_init();
        /* Module-Specific Initializations*/
        SYSCFG_DL_SYSCTL_init();
        SYSCFG_DL_PWM_0_init();
        SYSCFG_DL_TIMER_0_init();
        SYSCFG_DL_UART_0_init();
        SYSCFG_DL_ADC12_0_init();
        SYSCFG_DL_VREF_init();
        SYSCFG_DL_LCD_init();
    }
    
    SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
    {
        DL_GPIO_reset(GPIOA);
        DL_GPIO_reset(GPIOB);
        DL_GPIO_reset(GPIOC);
        DL_TimerA_reset(PWM_0_INST);
        DL_TimerG_reset(TIMER_0_INST);
        DL_UART_Main_reset(UART_0_INST);
        DL_ADC12_reset(ADC12_0_INST);
        DL_VREF_reset(VREF);
        DL_LCD_reset(LCD);
    
        DL_GPIO_enablePower(GPIOA);
        DL_GPIO_enablePower(GPIOB);
        DL_GPIO_enablePower(GPIOC);
        DL_TimerA_enablePower(PWM_0_INST);
        DL_TimerG_enablePower(TIMER_0_INST);
        DL_UART_Main_enablePower(UART_0_INST);
        DL_ADC12_enablePower(ADC12_0_INST);
        DL_VREF_enablePower(VREF);
        DL_LCD_enablePower(LCD);
        delay_cycles(POWER_STARTUP_DELAY);
    }
    
    SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void)
    {
    
        DL_GPIO_initPeripheralOutputFunction(GPIO_PWM_0_C0_IOMUX,GPIO_PWM_0_C0_IOMUX_FUNC);
        DL_GPIO_enableOutput(GPIO_PWM_0_C0_PORT, GPIO_PWM_0_C0_PIN);
    
        DL_GPIO_initPeripheralOutputFunction(
            GPIO_UART_0_IOMUX_TX, GPIO_UART_0_IOMUX_TX_FUNC);
        DL_GPIO_initPeripheralInputFunction(
            GPIO_UART_0_IOMUX_RX, GPIO_UART_0_IOMUX_RX_FUNC);
    
        DL_GPIO_initDigitalOutput(GPIO_LEDS_LED_1_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_LEDS_LED_2_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_LEDS_LED_3_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_VIBRATOR_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_GREEN_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_RED_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_BLUE_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_RM_SCL_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_RM_SDA_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_PIN_0_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_OTHER_M_PUMP_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_SCL_SDA_A_SCL1_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_SCL_SDA_A_SDA1_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_SCL_SDA_SEN_SDA_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_SCL_SDA_SEN_SCL_IOMUX);
    
        DL_GPIO_initDigitalInputFeatures(GPIO_SWITCH_MCU_TPS_EN_S_IOMUX,
    		 DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
    		 DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
    
        DL_GPIO_initDigitalOutput(GPIO_SWITCH_MCU_TPS_EN_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_FLSH_FLSH_SCK_IOMUX);
    
        DL_GPIO_initDigitalOutput(GPIO_FLSH_FLSH_SI_IOMUX);
    
        DL_GPIO_initDigitalInputFeatures(GPIO_FLSH_FLSH_SO_IOMUX,
    		 DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
    		 DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
    
        DL_GPIO_initDigitalOutput(GPIO_FLSH_FLSH_CE_IOMUX);
    
        DL_GPIO_initDigitalInputFeatures(GPIO_BATTERY_BQ_CHG_IOMUX,
    		 DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
    		 DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
    
        DL_GPIO_initDigitalInputFeatures(GPIO_BATTERY_BQ_PG_IOMUX,
    		 DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
    		 DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
    
        DL_GPIO_clearPins(GPIOA, GPIO_OTHER_PIN_0_PIN |
    		GPIO_SCL_SDA_SEN_SDA_PIN |
    		GPIO_SCL_SDA_SEN_SCL_PIN |
    		GPIO_SWITCH_MCU_TPS_EN_PIN);
        DL_GPIO_enableOutput(GPIOA, GPIO_OTHER_PIN_0_PIN |
    		GPIO_SCL_SDA_SEN_SDA_PIN |
    		GPIO_SCL_SDA_SEN_SCL_PIN |
    		GPIO_SWITCH_MCU_TPS_EN_PIN);
        DL_GPIO_clearPins(GPIOB, GPIO_OTHER_VIBRATOR_PIN |
    		GPIO_OTHER_M_PUMP_PIN |
    		GPIO_FLSH_FLSH_SCK_PIN |
    		GPIO_FLSH_FLSH_SI_PIN |
    		GPIO_FLSH_FLSH_CE_PIN);
        DL_GPIO_enableOutput(GPIOB, GPIO_OTHER_VIBRATOR_PIN |
    		GPIO_OTHER_M_PUMP_PIN |
    		GPIO_FLSH_FLSH_SCK_PIN |
    		GPIO_FLSH_FLSH_SI_PIN |
    		GPIO_FLSH_FLSH_CE_PIN);
        DL_GPIO_clearPins(GPIOC, GPIO_LEDS_LED_1_PIN |
    		GPIO_LEDS_LED_2_PIN |
    		GPIO_LEDS_LED_3_PIN |
    		GPIO_OTHER_RM_SCL_PIN |
    		GPIO_OTHER_RM_SDA_PIN |
    		GPIO_SCL_SDA_A_SCL1_PIN |
    		GPIO_SCL_SDA_A_SDA1_PIN);
        DL_GPIO_setPins(GPIOC, GPIO_OTHER_GREEN_PIN |
    		GPIO_OTHER_RED_PIN |
    		GPIO_OTHER_BLUE_PIN);
        DL_GPIO_enableOutput(GPIOC, GPIO_LEDS_LED_1_PIN |
    		GPIO_LEDS_LED_2_PIN |
    		GPIO_LEDS_LED_3_PIN |
    		GPIO_OTHER_GREEN_PIN |
    		GPIO_OTHER_RED_PIN |
    		GPIO_OTHER_BLUE_PIN |
    		GPIO_OTHER_RM_SCL_PIN |
    		GPIO_OTHER_RM_SDA_PIN |
    		GPIO_SCL_SDA_A_SCL1_PIN |
    		GPIO_SCL_SDA_A_SDA1_PIN);
    
    }
    
    
    
    SYSCONFIG_WEAK void SYSCFG_DL_SYSCTL_init(void)
    {
    
    	//Low Power Mode is configured to be SLEEP0
        DL_SYSCTL_setBORThreshold(DL_SYSCTL_BOR_THRESHOLD_LEVEL_0);
    
        
    	/* Enable SYSOSC FCL in Internal Resistor Mode */
    	DL_SYSCTL_enableSYSOSCFCL();
    	DL_SYSCTL_setSYSOSCFreq(DL_SYSCTL_SYSOSC_FREQ_4M);
        DL_SYSCTL_setMCLKDivider(DL_SYSCTL_MCLK_DIVIDER_2);
        DL_SYSCTL_enableMFCLK();
    
    }
    
    
    /*
     * Timer clock configuration to be sourced by  / 1 (4000000 Hz)
     * timerClkFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1)))
     *   1000000 Hz = 4000000 Hz / (1 * (3 + 1))
     */
    static const DL_TimerA_ClockConfig gPWM_0ClockConfig = {
        .clockSel = DL_TIMER_CLOCK_MFCLK,
        .divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
        .prescale = 3U
    };
    
    static const DL_TimerA_PWMConfig gPWM_0Config = {
        .pwmMode = DL_TIMER_PWM_MODE_EDGE_ALIGN,
        .period = 200,
        .isTimerWithFourCC = true,
        .startTimer = DL_TIMER_STOP,
    };
    
    SYSCONFIG_WEAK void SYSCFG_DL_PWM_0_init(void) {
    
        DL_TimerA_setClockConfig(
            PWM_0_INST, (DL_TimerA_ClockConfig *) &gPWM_0ClockConfig);
    
        DL_TimerA_initPWMMode(
            PWM_0_INST, (DL_TimerA_PWMConfig *) &gPWM_0Config);
    
        DL_TimerA_setCaptureCompareOutCtl(PWM_0_INST, DL_TIMER_CC_OCTL_INIT_VAL_LOW,
    		DL_TIMER_CC_OCTL_INV_OUT_DISABLED, DL_TIMER_CC_OCTL_SRC_FUNCVAL,
    		DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
    
        DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_ZERO_EVT, DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
        DL_TimerA_setCaptureCompareValue(PWM_0_INST, 100, DL_TIMER_CC_0_INDEX);
    
        DL_TimerA_enableClock(PWM_0_INST);
    
    
        DL_TimerA_enableInterrupt(PWM_0_INST , DL_TIMER_INTERRUPT_CC0_DN_EVENT);
    
        DL_TimerA_setCCPDirection(PWM_0_INST , DL_TIMER_CC0_OUTPUT );
        DL_TimerA_enableShadowFeatures(PWM_0_INST);
    
    
    }
    
    
    
    /*
     * Timer clock configuration to be sourced by LFCLK /  (32768 Hz)
     * timerClkFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1)))
     *   32768 Hz = 32768 Hz / (1 * (0 + 1))
     */
    static const DL_TimerG_ClockConfig gTIMER_0ClockConfig = {
        .clockSel    = DL_TIMER_CLOCK_LFCLK,
        .divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
        .prescale    = 0U,
    };
    
    /*
     * Timer load value (where the counter starts from) is calculated as (timerPeriod * timerClockFreq) - 1
     * TIMER_0_INST_LOAD_VALUE = (1ms * 32768 Hz) - 1
     */
    static const DL_TimerG_TimerConfig gTIMER_0TimerConfig = {
        .period     = TIMER_0_INST_LOAD_VALUE,
        .timerMode  = DL_TIMER_TIMER_MODE_PERIODIC,
        .startTimer = DL_TIMER_STOP,
    };
    
    SYSCONFIG_WEAK void SYSCFG_DL_TIMER_0_init(void) {
    
        DL_TimerG_setClockConfig(TIMER_0_INST,
            (DL_TimerG_ClockConfig *) &gTIMER_0ClockConfig);
    
        DL_TimerG_initTimerMode(TIMER_0_INST,
            (DL_TimerG_TimerConfig *) &gTIMER_0TimerConfig);
        DL_TimerG_enableInterrupt(TIMER_0_INST , DL_TIMERG_INTERRUPT_ZERO_EVENT);
        DL_TimerG_enableClock(TIMER_0_INST);
    
    
    
    
    
    }
    
    
    
    static const DL_UART_Main_ClockConfig gUART_0ClockConfig = {
        .clockSel    = DL_UART_MAIN_CLOCK_MFCLK,
        .divideRatio = DL_UART_MAIN_CLOCK_DIVIDE_RATIO_1
    };
    
    static const DL_UART_Main_Config gUART_0Config = {
        .mode        = DL_UART_MAIN_MODE_NORMAL,
        .direction   = DL_UART_MAIN_DIRECTION_TX_RX,
        .flowControl = DL_UART_MAIN_FLOW_CONTROL_NONE,
        .parity      = DL_UART_MAIN_PARITY_NONE,
        .wordLength  = DL_UART_MAIN_WORD_LENGTH_8_BITS,
        .stopBits    = DL_UART_MAIN_STOP_BITS_ONE
    };
    
    SYSCONFIG_WEAK void SYSCFG_DL_UART_0_init(void)
    {
        DL_UART_Main_setClockConfig(UART_0_INST, (DL_UART_Main_ClockConfig *) &gUART_0ClockConfig);
    
        DL_UART_Main_init(UART_0_INST, (DL_UART_Main_Config *) &gUART_0Config);
        /*
         * Configure baud rate by setting oversampling and baud rate divisors.
         *  Target baud rate: 9600
         *  Actual baud rate: 9598.08
         */
        DL_UART_Main_setOversampling(UART_0_INST, DL_UART_OVERSAMPLING_RATE_16X);
        DL_UART_Main_setBaudRateDivisor(UART_0_INST, UART_0_IBRD_4_MHZ_9600_BAUD, UART_0_FBRD_4_MHZ_9600_BAUD);
    
    
        /* Configure Interrupts */
        DL_UART_Main_enableInterrupt(UART_0_INST,
                                     DL_UART_MAIN_INTERRUPT_RX |
                                     DL_UART_MAIN_INTERRUPT_TX);
    
    
        DL_UART_Main_enable(UART_0_INST);
    }
    
    /* ADC12_0 Initialization */
    static const DL_ADC12_ClockConfig gADC12_0ClockConfig = {
        .clockSel       = DL_ADC12_CLOCK_ULPCLK,
        .divideRatio    = DL_ADC12_CLOCK_DIVIDE_48,
        .freqRange      = DL_ADC12_CLOCK_FREQ_RANGE_1_TO_4,
    };
    SYSCONFIG_WEAK void SYSCFG_DL_ADC12_0_init(void)
    {
        DL_ADC12_setClockConfig(ADC12_0_INST, (DL_ADC12_ClockConfig *) &gADC12_0ClockConfig);
    
        DL_ADC12_initSeqSample(ADC12_0_INST,
            DL_ADC12_REPEAT_MODE_DISABLED, DL_ADC12_SAMPLING_SOURCE_AUTO, DL_ADC12_TRIG_SRC_SOFTWARE,
            DL_ADC12_SEQ_START_ADDR_00, DL_ADC12_SEQ_END_ADDR_05, DL_ADC12_SAMP_CONV_RES_12_BIT,
            DL_ADC12_SAMP_CONV_DATA_FORMAT_UNSIGNED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_0,
            DL_ADC12_INPUT_CHAN_25, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_1,
            DL_ADC12_INPUT_CHAN_0, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_2,
            DL_ADC12_INPUT_CHAN_24, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_3,
            DL_ADC12_INPUT_CHAN_4, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_4,
            DL_ADC12_INPUT_CHAN_23, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_5,
            DL_ADC12_INPUT_CHAN_22, DL_ADC12_REFERENCE_VOLTAGE_INTREF, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
            DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
        /* Enable ADC12 interrupt */
        DL_ADC12_clearInterruptStatus(ADC12_0_INST,(DL_ADC12_INTERRUPT_MEM5_RESULT_LOADED));
        DL_ADC12_enableInterrupt(ADC12_0_INST,(DL_ADC12_INTERRUPT_MEM5_RESULT_LOADED));
        DL_ADC12_enableConversions(ADC12_0_INST);
    }
    
    
    static const DL_VREF_Config gVREFConfig = {
        .vrefEnable     = DL_VREF_ENABLE_ENABLE,
        .bufConfig      = DL_VREF_BUFCONFIG_OUTPUT_2_5V,
        .shModeEnable   = DL_VREF_SHMODE_DISABLE,
        .holdCycleCount = DL_VREF_HOLD_MIN,
        .shCycleCount   = DL_VREF_SH_MIN,
    };
    
    SYSCONFIG_WEAK void SYSCFG_DL_VREF_init(void) {
        DL_VREF_configReference(VREF,
            (DL_VREF_Config *) &gVREFConfig);
    }
    
    
    static const DL_LCD_Config gLCDConfig = {
        .frequencyDivider   = DL_LCD_FREQ_DIVIDE_16,
        .muxRate            = DL_LCD_MUX_RATE_8,
        .lowPowerWaveform   = DL_LCD_WAVEFORM_POWERMODE_LOWPOWER
    };
    
    SYSCONFIG_WEAK void SYSCFG_DL_LCD_init(void)
    {
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_30);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_31);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_32);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_33);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_34);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_35);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_36);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_37);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_0);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_38);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_28);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_27);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_26);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_25);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_24);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_23);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_22);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_21);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_20);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_19);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_18);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_16);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_15);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_14);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_13);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_12);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_11);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_10);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_9);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_8);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_7);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_6);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_5);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_4);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_3);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_2);
        DL_LCD_setPinAsLCDFunction(LCD, DL_LCD_SEGMENT_LINE_1);
        DL_LCD_init(LCD, (DL_LCD_Config *) &gLCDConfig);
        DL_LCD_turnSegmentsOn(LCD);
        DL_LCD_setBiasVoltageSource(LCD, DL_LCD_BIAS_VOLTAGE_SOURCE_AVDD);
        DL_LCD_setR33source(LCD, DL_LCD_R33_SOURCE_EXTERNAL);
        DL_LCD_enableInternalBias(LCD);
        DL_LCD_setInternalBiasPowerMode(LCD, DL_LCD_POWER_MODE_LOW);
        DL_LCD_setBias(LCD, DL_LCD_BIAS_ONE_THIRD);
    
        DL_LCD_clearAllMemoryRegs(LCD); //
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_30, DL_LCD_COM_0);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_31, DL_LCD_COM_1);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_32, DL_LCD_COM_2);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_33, DL_LCD_COM_3);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_34, DL_LCD_COM_4);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_35, DL_LCD_COM_5);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_36, DL_LCD_COM_6);
        DL_LCD_setPinAsCommon(LCD, DL_LCD_SEGMENT_LINE_37, DL_LCD_COM_7);
        DL_LCD_enable(LCD);
    }
    
    

    /*
     * Copyright (c) 2023, Texas Instruments Incorporated - http://www.ti.com
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ============ ti_msp_dl_config.h =============
     *  Configured MSPM0 DriverLib module declarations
     *
     *  DO NOT EDIT - This file is generated for the MSPM0L222X
     *  by the SysConfig tool.
     */
    #ifndef ti_msp_dl_config_h
    #define ti_msp_dl_config_h
    
    #define CONFIG_MSPM0L222X
    #define CONFIG_MSPM0L2228
    
    #if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
    #define SYSCONFIG_WEAK __attribute__((weak))
    #elif defined(__IAR_SYSTEMS_ICC__)
    #define SYSCONFIG_WEAK __weak
    #elif defined(__GNUC__)
    #define SYSCONFIG_WEAK __attribute__((weak))
    #endif
    
    #include <ti/devices/msp/msp.h>
    #include <ti/driverlib/driverlib.h>
    #include <ti/driverlib/m0p/dl_core.h>
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /*
     *  ======== SYSCFG_DL_init ========
     *  Perform all required MSP DL initialization
     *
     *  This function should be called once at a point before any use of
     *  MSP DL.
     */
    
    
    /* clang-format off */
    
    #define POWER_STARTUP_DELAY                                                (16)
    
    
    
    #define CPUCLK_FREQ                                                      2000000
    
    
    
    /* Defines for PWM_0 */
    #define PWM_0_INST                                                         TIMA0
    #define PWM_0_INST_IRQHandler                                   TIMA0_IRQHandler
    #define PWM_0_INST_INT_IRQN                                     (TIMA0_INT_IRQn)
    #define PWM_0_INST_CLK_FREQ                                              1000000
    /* GPIO defines for channel 0 */
    #define GPIO_PWM_0_C0_PORT                                                 GPIOA
    #define GPIO_PWM_0_C0_PIN                                          DL_GPIO_PIN_2
    #define GPIO_PWM_0_C0_IOMUX                                       (IOMUX_PINCM7)
    #define GPIO_PWM_0_C0_IOMUX_FUNC                      IOMUX_PINCM7_PF_TIMA0_CCP0
    #define GPIO_PWM_0_C0_IDX                                    DL_TIMER_CC_0_INDEX
    
    
    
    /* Defines for TIMER_0 */
    #define TIMER_0_INST                                                     (TIMG0)
    #define TIMER_0_INST_IRQHandler                                 TIMG0_IRQHandler
    #define TIMER_0_INST_INT_IRQN                                   (TIMG0_INT_IRQn)
    #define TIMER_0_INST_LOAD_VALUE                                            (32U)
    
    
    
    /* Defines for UART_0 */
    #define UART_0_INST                                                        UART0
    #define UART_0_INST_FREQUENCY                                            4000000
    #define UART_0_INST_IRQHandler                                  UART0_IRQHandler
    #define UART_0_INST_INT_IRQN                                      UART0_INT_IRQn
    #define GPIO_UART_0_RX_PORT                                                GPIOA
    #define GPIO_UART_0_TX_PORT                                                GPIOA
    #define GPIO_UART_0_RX_PIN                                         DL_GPIO_PIN_1
    #define GPIO_UART_0_TX_PIN                                         DL_GPIO_PIN_0
    #define GPIO_UART_0_IOMUX_RX                                      (IOMUX_PINCM2)
    #define GPIO_UART_0_IOMUX_TX                                      (IOMUX_PINCM1)
    #define GPIO_UART_0_IOMUX_RX_FUNC                       IOMUX_PINCM2_PF_UART0_RX
    #define GPIO_UART_0_IOMUX_TX_FUNC                       IOMUX_PINCM1_PF_UART0_TX
    #define UART_0_BAUD_RATE                                                  (9600)
    #define UART_0_IBRD_4_MHZ_9600_BAUD                                         (26)
    #define UART_0_FBRD_4_MHZ_9600_BAUD                                          (3)
    
    
    
    
    
    /* Defines for ADC12_0 */
    #define ADC12_0_INST                                                        ADC0
    #define ADC12_0_INST_IRQHandler                                  ADC0_IRQHandler
    #define ADC12_0_INST_INT_IRQN                                    (ADC0_INT_IRQn)
    #define ADC12_0_ADCMEM_0                                      DL_ADC12_MEM_IDX_0
    #define ADC12_0_ADCMEM_0_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_0_REF_VOLTAGE_V                                      2.50
    #define ADC12_0_ADCMEM_1                                      DL_ADC12_MEM_IDX_1
    #define ADC12_0_ADCMEM_1_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_1_REF_VOLTAGE_V                                      2.50
    #define ADC12_0_ADCMEM_2                                      DL_ADC12_MEM_IDX_2
    #define ADC12_0_ADCMEM_2_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_2_REF_VOLTAGE_V                                      2.50
    #define ADC12_0_ADCMEM_3                                      DL_ADC12_MEM_IDX_3
    #define ADC12_0_ADCMEM_3_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_3_REF_VOLTAGE_V                                      2.50
    #define ADC12_0_ADCMEM_4                                      DL_ADC12_MEM_IDX_4
    #define ADC12_0_ADCMEM_4_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_4_REF_VOLTAGE_V                                      2.50
    #define ADC12_0_ADCMEM_5                                      DL_ADC12_MEM_IDX_5
    #define ADC12_0_ADCMEM_5_REF                   DL_ADC12_REFERENCE_VOLTAGE_INTREF
    #define ADC12_0_ADCMEM_5_REF_VOLTAGE_V                                      2.50
    #define GPIO_ADC12_0_C0_PORT                                               GPIOA
    #define GPIO_ADC12_0_C0_PIN                                       DL_GPIO_PIN_27
    #define GPIO_ADC12_0_C4_PORT                                               GPIOB
    #define GPIO_ADC12_0_C4_PIN                                       DL_GPIO_PIN_25
    
    
    /* Defines for VREF */
    #define VREF_VOLTAGE_MV                                                     2500
    
    
    
    
    /* Port definition for Pin Group GPIO_LEDS */
    #define GPIO_LEDS_PORT                                                   (GPIOC)
    
    /* Defines for LED_1: GPIOC.5 with pinCMx 48 on package pin 53 */
    #define GPIO_LEDS_LED_1_PIN                                      (DL_GPIO_PIN_5)
    #define GPIO_LEDS_LED_1_IOMUX                                    (IOMUX_PINCM48)
    /* Defines for LED_2: GPIOC.4 with pinCMx 47 on package pin 52 */
    #define GPIO_LEDS_LED_2_PIN                                      (DL_GPIO_PIN_4)
    #define GPIO_LEDS_LED_2_IOMUX                                    (IOMUX_PINCM47)
    /* Defines for LED_3: GPIOC.0 with pinCMx 43 on package pin 46 */
    #define GPIO_LEDS_LED_3_PIN                                      (DL_GPIO_PIN_0)
    #define GPIO_LEDS_LED_3_IOMUX                                    (IOMUX_PINCM43)
    /* Defines for VIBRATOR: GPIOB.0 with pinCMx 12 on package pin 15 */
    #define GPIO_OTHER_VIBRATOR_PORT                                         (GPIOB)
    #define GPIO_OTHER_VIBRATOR_PIN                                  (DL_GPIO_PIN_0)
    #define GPIO_OTHER_VIBRATOR_IOMUX                                (IOMUX_PINCM12)
    /* Defines for GREEN: GPIOC.2 with pinCMx 45 on package pin 50 */
    #define GPIO_OTHER_GREEN_PORT                                            (GPIOC)
    #define GPIO_OTHER_GREEN_PIN                                     (DL_GPIO_PIN_2)
    #define GPIO_OTHER_GREEN_IOMUX                                   (IOMUX_PINCM45)
    /* Defines for RED: GPIOC.1 with pinCMx 44 on package pin 47 */
    #define GPIO_OTHER_RED_PORT                                              (GPIOC)
    #define GPIO_OTHER_RED_PIN                                       (DL_GPIO_PIN_1)
    #define GPIO_OTHER_RED_IOMUX                                     (IOMUX_PINCM44)
    /* Defines for BLUE: GPIOC.3 with pinCMx 46 on package pin 51 */
    #define GPIO_OTHER_BLUE_PORT                                             (GPIOC)
    #define GPIO_OTHER_BLUE_PIN                                      (DL_GPIO_PIN_3)
    #define GPIO_OTHER_BLUE_IOMUX                                    (IOMUX_PINCM46)
    /* Defines for RM_SCL: GPIOC.7 with pinCMx 59 on package pin 64 */
    #define GPIO_OTHER_RM_SCL_PORT                                           (GPIOC)
    #define GPIO_OTHER_RM_SCL_PIN                                    (DL_GPIO_PIN_7)
    #define GPIO_OTHER_RM_SCL_IOMUX                                  (IOMUX_PINCM59)
    /* Defines for RM_SDA: GPIOC.6 with pinCMx 58 on package pin 63 */
    #define GPIO_OTHER_RM_SDA_PORT                                           (GPIOC)
    #define GPIO_OTHER_RM_SDA_PIN                                    (DL_GPIO_PIN_6)
    #define GPIO_OTHER_RM_SDA_IOMUX                                  (IOMUX_PINCM58)
    /* Defines for PIN_0: GPIOA.18 with pinCMx 50 on package pin 55 */
    #define GPIO_OTHER_PIN_0_PORT                                            (GPIOA)
    #define GPIO_OTHER_PIN_0_PIN                                    (DL_GPIO_PIN_18)
    #define GPIO_OTHER_PIN_0_IOMUX                                   (IOMUX_PINCM50)
    /* Defines for M_PUMP: GPIOB.23 with pinCMx 65 on package pin 70 */
    #define GPIO_OTHER_M_PUMP_PORT                                           (GPIOB)
    #define GPIO_OTHER_M_PUMP_PIN                                   (DL_GPIO_PIN_23)
    #define GPIO_OTHER_M_PUMP_IOMUX                                  (IOMUX_PINCM65)
    /* Defines for A_SCL1: GPIOC.8 with pinCMx 60 on package pin 65 */
    #define GPIO_SCL_SDA_A_SCL1_PORT                                         (GPIOC)
    #define GPIO_SCL_SDA_A_SCL1_PIN                                  (DL_GPIO_PIN_8)
    #define GPIO_SCL_SDA_A_SCL1_IOMUX                                (IOMUX_PINCM60)
    /* Defines for A_SDA1: GPIOC.9 with pinCMx 61 on package pin 66 */
    #define GPIO_SCL_SDA_A_SDA1_PORT                                         (GPIOC)
    #define GPIO_SCL_SDA_A_SDA1_PIN                                  (DL_GPIO_PIN_9)
    #define GPIO_SCL_SDA_A_SDA1_IOMUX                                (IOMUX_PINCM61)
    /* Defines for SEN_SDA: GPIOA.5 with pinCMx 10 on package pin 13 */
    #define GPIO_SCL_SDA_SEN_SDA_PORT                                        (GPIOA)
    #define GPIO_SCL_SDA_SEN_SDA_PIN                                 (DL_GPIO_PIN_5)
    #define GPIO_SCL_SDA_SEN_SDA_IOMUX                               (IOMUX_PINCM10)
    /* Defines for SEN_SCL: GPIOA.6 with pinCMx 11 on package pin 14 */
    #define GPIO_SCL_SDA_SEN_SCL_PORT                                        (GPIOA)
    #define GPIO_SCL_SDA_SEN_SCL_PIN                                 (DL_GPIO_PIN_6)
    #define GPIO_SCL_SDA_SEN_SCL_IOMUX                               (IOMUX_PINCM11)
    /* Defines for MCU_TPS_EN_S: GPIOB.1 with pinCMx 13 on package pin 16 */
    #define GPIO_SWITCH_MCU_TPS_EN_S_PORT                                    (GPIOB)
    #define GPIO_SWITCH_MCU_TPS_EN_S_PIN                             (DL_GPIO_PIN_1)
    #define GPIO_SWITCH_MCU_TPS_EN_S_IOMUX                           (IOMUX_PINCM13)
    /* Defines for MCU_TPS_EN: GPIOA.7 with pinCMx 14 on package pin 17 */
    #define GPIO_SWITCH_MCU_TPS_EN_PORT                                      (GPIOA)
    #define GPIO_SWITCH_MCU_TPS_EN_PIN                               (DL_GPIO_PIN_7)
    #define GPIO_SWITCH_MCU_TPS_EN_IOMUX                             (IOMUX_PINCM14)
    /* Port definition for Pin Group GPIO_FLSH */
    #define GPIO_FLSH_PORT                                                   (GPIOB)
    
    /* Defines for FLSH_SCK: GPIOB.28 with pinCMx 21 on package pin 24 */
    #define GPIO_FLSH_FLSH_SCK_PIN                                  (DL_GPIO_PIN_28)
    #define GPIO_FLSH_FLSH_SCK_IOMUX                                 (IOMUX_PINCM21)
    /* Defines for FLSH_SI: GPIOB.29 with pinCMx 22 on package pin 25 */
    #define GPIO_FLSH_FLSH_SI_PIN                                   (DL_GPIO_PIN_29)
    #define GPIO_FLSH_FLSH_SI_IOMUX                                  (IOMUX_PINCM22)
    /* Defines for FLSH_SO: GPIOB.30 with pinCMx 23 on package pin 26 */
    #define GPIO_FLSH_FLSH_SO_PIN                                   (DL_GPIO_PIN_30)
    #define GPIO_FLSH_FLSH_SO_IOMUX                                  (IOMUX_PINCM23)
    /* Defines for FLSH_CE: GPIOB.31 with pinCMx 24 on package pin 27 */
    #define GPIO_FLSH_FLSH_CE_PIN                                   (DL_GPIO_PIN_31)
    #define GPIO_FLSH_FLSH_CE_IOMUX                                  (IOMUX_PINCM24)
    /* Port definition for Pin Group GPIO_BATTERY */
    #define GPIO_BATTERY_PORT                                                (GPIOB)
    
    /* Defines for BQ_CHG: GPIOB.2 with pinCMx 15 on package pin 18 */
    #define GPIO_BATTERY_BQ_CHG_PIN                                  (DL_GPIO_PIN_2)
    #define GPIO_BATTERY_BQ_CHG_IOMUX                                (IOMUX_PINCM15)
    /* Defines for BQ_PG: GPIOB.3 with pinCMx 16 on package pin 19 */
    #define GPIO_BATTERY_BQ_PG_PIN                                   (DL_GPIO_PIN_3)
    #define GPIO_BATTERY_BQ_PG_IOMUX                                 (IOMUX_PINCM16)
    
    
    /* Defines for LCD */
    #define LCD_IRQHandler                                            LCD_IRQHandler
    #define LCD_INT_IRQN                                                LCD_INT_IRQn
    
    /* clang-format on */
    
    void SYSCFG_DL_init(void);
    void SYSCFG_DL_initPower(void);
    void SYSCFG_DL_GPIO_init(void);
    void SYSCFG_DL_SYSCTL_init(void);
    void SYSCFG_DL_PWM_0_init(void);
    void SYSCFG_DL_TIMER_0_init(void);
    void SYSCFG_DL_UART_0_init(void);
    void SYSCFG_DL_ADC12_0_init(void);
    void SYSCFG_DL_VREF_init(void);
    
    void SYSCFG_DL_LCD_init(void);
    
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* ti_msp_dl_config_h */
    

    1) I attached ti_msp_dl_config.c and ti_msp_dl_config.h file check once my configuration is ok or not.

    2) Yes, But not 32KHz I configure SYSOSC has 4MHz .so device is functioning at 4MHz when plugged in, but it's working 32MHz when Unplugged .

    3) My Expected configured frequency based on clock tree . I attached clock tree images below 

    clock tree

  • Hi,

    "Yes, But not 32KHz I configure SYSOSC has 4MHz .so device is functioning at 4MHz when plugged in, but it's working 32MHz when Unplugged ."

    It sounds like your SYSOSC frequency is switching between 4MHz to 32MHz when it is unplugged -- is this correct?

    When your device is unplugged --> does it completely lose power?

    -Matthew