Query Regarding VLPS Mode Entry ins S32K146

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Query Regarding VLPS Mode Entry ins S32K146

3,423件の閲覧回数
KKB
Contributor I

I am facing a problem here regarding the entry to VLPS mode in S32K146 MCU. The Code goes into VLPS Mode if i use POWER_SYS_SetMode() API before isl_init() function which uses LPSPI Master Transfer Blocking function to initialize my AFE and comes back to RUN Mode on GPIO Interrupt but if i use the POWER_SYS_SetMode()  after isl_init(), the API returns with STATUS_SUCCESS immediately on that instance without any interrupt triggered

/* ###################################################################
 **     Filename    : main.c
 **     Processor   : S32K1xx
 **     Abstract    :
 **         Main module.
 **         This module contains user's application code.
 **     Settings    :
 **     Contents    :
 **         No public methods
 **
 ** ###################################################################*/
/*!
 ** @file main.c
 ** @version 01.00
 ** @brief
 **         Main module.
 **         This module contains user's application code.
 */
/*!
 **  @addtogroup main_module main module documentation
 **  @{
 */
/* MODULE main */

/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"
#include "main.h"

volatile int exit_code = 0;


/* User includes (#include below this line is not maintained by Processor Expert) */

/*!
 \brief The main function for the project.
 \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
int main(void) {
	/* Write your local variable definition here */

	/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
	PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
	/*** End of Processor Expert internal initialization.                    ***/
	/* Write your code here */
	// Battery Parameters
	EMO_param.pack_over_voltage_limit = 58.8;
	EMO_param.pack_under_voltage_limit = 35.0;
	EMO_param.cell_over_voltage_limit = 4.200;
	EMO_param.cell_under_voltage_limit = 2.500;
	EMO_param.charger_request_voltage = 58.1;
	EMO_param.charger_request_current = 45.0;
	EMO_param.charging_float_voltage = 57.5;
	EMO_param.voltage_overshoot_threshold = 60;
	EMO_param.discharging_float_voltage = 37.0;
	EMO_param.over_current_limit_discharging = 144.0;
	EMO_param.mosfet_gain_test = 0x78;
	EMO_param.current_offset_test = 4;
	EMO_param.over_tempurature_limit = 58;
	EMO_param.tempurature_fan_on = 45;
	EMO_param.tempurature_fan_off = 40;
	EMO_param.dod_max_voltage = 42;
	EMO_param.dod_min_voltage = 25;
	EMO_param.charger_end_current = 4;

	// Initialize the peripherals and it's applications
	peripheral_init();
	peripheral_initialize();
	// Initialize the battery configurations and it's parameters
	battery_config(&EMO_param);
	LL_mDelay(100);
	// State is idle and event1
	bms_sm_T = sleep;
	bms_event_T = event1;

	// Initialize the AFE
	ISL78714_status_T = isl_init();
	if (ISL78714_status_T == E_OK) {
		for (uint8_t i = 0; i < no_of_devices; i++) {
			ISL78714_status_T = measurment_fault_detect(ADDRESS_OFFSET + i);
			module_param_T[i] = module_param();
			ISL78714_status_T = fault_read(ADDRESS_OFFSET + i);
			module_param_T[i] = module_fault();
			battery_param[0] = 0U;
			battery_param[1] = 0U;
			battery_param[2] = 0U;
			battery_param[3] = 0U;
			battery_param[4] = module_param_T[0].modV >> 8;
			battery_param[5] = module_param_T[0].modV;
			battery_param[6] = module_error[0];
			battery_param[7] = 0U;
		}
	}
	else {
		SET(module_error[0], AFE_COM_ERROR);
	}
	
	/* Set power mode to VLPS */
	status_t retV = POWER_SYS_SetMode(VLPS_Mode, POWER_MANAGER_POLICY_AGREEMENT);
	if (retV == STATUS_SUCCESS) {
		if (POWER_SYS_GetCurrentMode() == POWER_MANAGER_RUN) {
			PINS_DRV_WritePin(PTD, 10U, 0);
			PINS_DRV_WritePin(PTD, 11U, 1);
			bms_sm_T = init;
			bms_event_T = event1;
			break;
		} else {
			PINS_DRV_WritePin(PTD, 10U, 1);
			PINS_DRV_WritePin(PTD, 11U, 0);
		}
	}

	LL_mDelay(10);

	while (1) {
#if V4
		// Toggle the LED
		PINS_DRV_TogglePins(PTD, 1 << 10U);
		PINS_DRV_TogglePins(PTD, 1 << 11U);
#endif
		bms_sm();
	}
	/* For example: for(;;) { } */

	/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
 ** @}
 */
/*
 ** ###################################################################
 **
 **     This file was created by Processor Expert 10.1 [05.21]
 **     for the NXP S32K series of microcontrollers.
 **
 ** ###################################################################
 */

 

0 件の賞賛
返信
7 返答(返信)

3,397件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @KKB,

Once the WFI instruction is executed, there must be an interrupt that brings it back. You can try masking the interrupt just before WFI (PRIMASK = 1), it will then not wakeup.

danielmartynek_0-1734605544853.png

Check the NVIC for any pending interrupts right before it goes to VLPS.

 

Regards,

Daniel

0 件の賞賛
返信

3,387件の閲覧回数
KKB
Contributor I

I have used INT_SYS_DisableIRQGlobal() before going to VLPS mode, still it comes out of VLPS even no Interrupt is triggered. I de-initialized all the peripherals before going to sleep and used the INT_SYS_GetPending to get pending interrupt and there is no pending interrupt as the API returns 0.

0 件の賞賛
返信

3,384件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Is SMC_PMCTRL[VLPSA] set after WFI?

 

Thank you

 

0 件の賞賛
返信

3,379件の閲覧回数
KKB
Contributor I
I didn't get your question, All i am doing is in debug mode before isl_init(), my MCU is going to VLPS and comes out of VLPS when pin interrupt is provided, but if i use the VLPS API after isl_init() which uses LPSPI and there is no ISR assigned to it, it immediately without any interrupt with STATUS_SUCCESS
0 件の賞賛
返信

3,375件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Can you place breakpoint after STANDBY() and read SMC_PMCTRL[VLPSA] in register view.

If the bit is set, the VLPS entry gets aborted.

It might be because of the LPSPI module.

Can you disable the LPSPI before POWER_SYS_SetMode(VLPS_Mode, ...) is called?

 

 

 

0 件の賞賛
返信

3,345件の閲覧回数
KKB
Contributor I

I have put the break point after STANDBY(), and it bypassed the breakpoint, and have read the register values and also de-initialized the LPSPI and disabled the Global IRQ.

/* ###################################################################
 **     Filename    : main.c
 **     Processor   : S32K1xx
 **     Abstract    :
 **         Main module.
 **         This module contains user's application code.
 **     Settings    :
 **     Contents    :
 **         No public methods
 **
 ** ###################################################################*/
/*!
 ** @file main.c
 ** @version 01.00
 ** @brief
 **         Main module.
 **         This module contains user's application code.
 */
/*!
 **  @addtogroup main_module main module documentation
 **  @{
 */
/* MODULE main */

/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"
#include "main.h"

volatile int exit_code = 0;


/* User includes (#include below this line is not maintained by Processor Expert) */

/*!
 \brief The main function for the project.
 \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
int main(void) {
	/* Write your local variable definition here */
	uint32_t pend = 0;
	/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
	PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
	/*** End of Processor Expert internal initialization.                    ***/
	/* Write your code here */
	// Battery Parameters
	EMO_param.pack_over_voltage_limit = 58.8;
	EMO_param.pack_under_voltage_limit = 35.0;
	EMO_param.cell_over_voltage_limit = 4.200;
	EMO_param.cell_under_voltage_limit = 2.500;
	EMO_param.charger_request_voltage = 58.1;
	EMO_param.charger_request_current = 45.0;
	EMO_param.charging_float_voltage = 57.5;
	EMO_param.voltage_overshoot_threshold = 60;
	EMO_param.discharging_float_voltage = 37.0;
	EMO_param.over_current_limit_discharging = 144.0;
	EMO_param.mosfet_gain_test = 0x78;
	EMO_param.current_offset_test = 4;
	EMO_param.over_tempurature_limit = 58;
	EMO_param.tempurature_fan_on = 45;
	EMO_param.tempurature_fan_off = 40;
	EMO_param.dod_max_voltage = 42;
	EMO_param.dod_min_voltage = 25;
	EMO_param.charger_end_current = 4;

	// Initialize the peripherals and it's applications
	peripheral_init();
	peripheral_initialize();
//	 Initialize the battery configurations and it's parameters
	battery_config(&EMO_param);
	LL_mDelay(100);
	// State is idle and event1
	bms_sm_T = sleep;
	bms_event_T = event1;
//
//	status_t retV = POWER_SYS_SetMode(1U, POWER_MANAGER_POLICY_AGREEMENT);
//	if (retV == STATUS_SUCCESS) {
//		if (POWER_SYS_GetCurrentMode() == POWER_MANAGER_RUN) {
//			PINS_DRV_WritePin(PTD, 10U, 0);
//			PINS_DRV_WritePin(PTD, 11U, 1);
//			bms_sm_T = init;
//			bms_event_T = event1;
//		} else {
//			PINS_DRV_WritePin(PTD, 10U, 1);
//			PINS_DRV_WritePin(PTD, 11U, 0);
//		}
//	}

	// Initialize the AFE
	ISL78714_status_T = isl_init();
	if (ISL78714_status_T == E_OK) {
		for (uint8_t i = 0; i < no_of_devices; i++) {
			ISL78714_status_T = measurment_fault_detect(ADDRESS_OFFSET + i);
			module_param_T[i] = module_param();
			ISL78714_status_T = fault_read(ADDRESS_OFFSET + i);
			module_param_T[i] = module_fault();
			battery_param[0] = 0U;
			battery_param[1] = 0U;
			battery_param[2] = 0U;
			battery_param[3] = 0U;
			battery_param[4] = module_param_T[0].modV >> 8;
			battery_param[5] = module_param_T[0].modV;
			battery_param[6] = module_error[0];
			battery_param[7] = 0U;
		}
	}
	else {
		SET(module_error[0], AFE_COM_ERROR);
	}

	//peripheral_deinit();
	LPSPI_DRV_MasterDeinit(LPSPICOM1);

	INT_SYS_DisableIRQGlobal();

	/* Set power mode to VLPS */
	status_t retV = POWER_SYS_SetMode(1U, POWER_MANAGER_POLICY_AGREEMENT);
	if (retV == STATUS_SUCCESS) {
		if (POWER_SYS_GetCurrentMode() == POWER_MANAGER_RUN) {
			PINS_DRV_WritePin(PTD, 10U, 0);
			PINS_DRV_WritePin(PTD, 11U, 1);
			bms_sm_T = init;
			bms_event_T = event1;
		} else {
			PINS_DRV_WritePin(PTD, 10U, 1);
			PINS_DRV_WritePin(PTD, 11U, 0);
		}
	}

	LL_mDelay(10);

	while (1) {
#if V4
		// Toggle the LED
		PINS_DRV_TogglePins(PTD, 1 << 10U);
		PINS_DRV_TogglePins(PTD, 1 << 11U);
#endif
		bms_sm();
	}
	/* For example: for(;;) { } */

	/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
 ** @}
 */
/*
 ** ###################################################################
 **
 **     This file was created by Processor Expert 10.1 [05.21]
 **     for the NXP S32K series of microcontrollers.
 **
 ** ###################################################################
 */
0 件の賞賛
返信

3,271件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Thank you, I understand the VLPS is not aborted, there is not wakeup (interrupt masked/disabled), and peripherals that are not used in VLPS are disabled before WFI.

Can you disconnect the debugger, power cycle the MCU and check the state of the MCU by measuing the power consumption of VDD and the BUS_CLK at CLKOUT?

 

Regards,

Daniel

0 件の賞賛
返信