cancel
Showing results for 
Search instead for 
Did you mean: 

MC SDK not work with MCU Stop mode

Guopeng
Associate II

Dears,

Currently I'm working on a BLDC project, and with the MC SDK, we can control the motor.

And we also want to make the MCU(STM32F4) into STOP mode to save some power, the issue is the MCU can not goes into STOP mode, anyone tried this before?

The code:

void McuEnterStopMode(void)
{
    __disable_irq();
    HAL_CAN_Stop(&hcan1);
    HAL_SuspendTick();
    HAL_TIM_Base_Stop(&htim1);
    HAL_TIM_Base_Stop(&htim3);
    HAL_NVIC_DisableIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_DisableIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_DisableIRQ(TIM3_IRQn);
    HAL_NVIC_DisableIRQ(TIM7_IRQn);
    HAL_NVIC_DisableIRQ(FPU_IRQn);
    htim1.Instance->CR1 &= ~(TIM_CR1_CEN);
    htim3.Instance->CR1 &= ~(TIM_CR1_CEN);
    htim1.Instance->SR = 0;
    htim3.Instance->SR = 0;
    TIM7->CR1 &= ~(TIM_CR1_CEN);
    TIM7->SR = 0;
    TIM3->CR1 &= ~(TIM_CR1_CEN);
    TIM3->SR = 0;
 
    ClearFPU();
 
    HAL_NVIC_ClearPendingIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_ClearPendingIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_ClearPendingIRQ(TIM3_IRQn);
    HAL_NVIC_ClearPendingIRQ(TIM7_IRQn);
    HAL_NVIC_ClearPendingIRQ(FPU_IRQn);
 
    // 3. 进入stop
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
    __enable_irq();
    HAL_ResumeTick();
    HAL_Init();
    MX_NVIC_Init();
    SystemClock_Config();
    HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/SYS_TICK_FREQUENCY);
    HAL_CAN_Start(&hcan1);
    HAL_TIM_Base_Start(&htim1);
    HAL_TIM_Base_Start(&htim3);
    HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);
    HAL_NVIC_EnableIRQ(TIM3_IRQn);
    HAL_NVIC_EnableIRQ(TIM7_IRQn);
    HAL_NVIC_EnableIRQ(FPU_IRQn);
}

Before calling below code, I checked, no pending interrupt, also for EXTI.

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

0693W00000Sv4dmQAB.jpg0693W00000Sv4dwQAB.jpgAnd I had tried if I do not call the MX_MotorControl_Init(line30) in main, the sleep and wakeup both work, anyone can provide some suggestions?

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_ADC2_Init();
  MX_TIM1_Init();
  MX_TIM3_Init();
  MX_USART1_UART_Init();
  MX_MotorControl_Init();
  MX_SPI2_Init();
  MX_SPI1_Init();
  MX_UART5_Init();
  MX_CAN1_Init();
 
  /* Initialize interrupts */
  MX_NVIC_Init();
  /* USER CODE BEGIN 2 */

Thanks�?​

10 REPLIES 10

You can probably choose a DC-DC converter, which is more suited for your needs. When choosing, you have to look for a "quiescent current" parameter. There are many converters from many manufacturers with a much lower values for that parameter. ST's L6983C33 is a good example, but just one of many.