cancel
Showing results for 
Search instead for 
Did you mean: 

MC SDK long response time after wakeup from stop mode

Guopeng
Associate II

I'm working on a project whith use a STM32F407 MCU to control a bldc motor and also has a low power mode, the mcu will into stop mode.

Now the stop mode is working, and we have issue to control the motor after wake up from stop mode.

the code to entere and exit the stop mode

void McuEnterStopMode(void)
{
 
    // HAL_ADC_DeInit(&hadc1);
    // HAL_ADC_DeInit(&hadc2);
 
    HAL_GPIO_WritePin(RELAY_GPIO_Port, RELAY_Pin, GPIO_PIN_RESET);
 
    //GPIOInitForStop();
    // 3. 进入stop
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 
    SystemClock_Config();
    HAL_GPIO_WritePin(RELAY_GPIO_Port, RELAY_Pin, GPIO_PIN_SET);
    MC_AcknowledgeFaultMotor1();
    MC_StartMotor1();
    //MX_ADC1_Init();
   // MX_ADC2_Init();
}

Also we tried to send the motor speed and status to the CAN bus, below is the code

void CAN_SendMotorSpeed(int16_t s)
{
    CAN_TxHeaderTypeDef CAN_tx;                                  //�?��?数�?�结构体
    uint8_t             tx_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };  //待�?��?的数�?�
    uint32_t            tx_mailbox;                              //�?置�?��?邮箱,定义一个�?��?就行,�?用赋值
    uint32_t            std_id = 0x601;                          //�?置�?��?id
 
    CanMsgCnt++;
    CAN_tx.DLC                = 8;           //�?��?数�?�长度
    CAN_tx.StdId              = std_id;      //�?��?数�?�的ID
    CAN_tx.IDE                = CAN_ID_STD;  //标准帧
    CAN_tx.TransmitGlobalTime = DISABLE;
    CAN_tx.RTR                = CAN_RTR_DATA;  //数�?�帧
    tx_data[0] = CanMsgCnt/255;
    tx_data[1] = CanMsgCnt&255;
    tx_data[2] = (uint16_t)s/255;
    tx_data[3] = (uint16_t)s & 255;
    tx_data[4] = MC_GetSTMStateMotor1();
 
    HAL_CAN_AddTxMessage(&hcan1, &CAN_tx, tx_data, &tx_mailbox);  //�?��?数�?�
}

​The main loop of the TJA1145 task:

void Tja1145_main(void)
{
    /* Write your local variable definition here */
    StdReturn_t     ret;
    PendingTask_t   task;
    uint8_t         req = 0;
    static uint32_t cnt11;
 
    extern void    CAN_Post_Init(void);
    extern void    CAN_SendMotorSpeed(signed short s);
    extern uint8_t CheckCanRequestSleepMode(void);
 
    // Operation set-up
    ret = StartupOperation();
    CAN_Post_Init();
    // if (ret == E_OK)
    {
        // Default Application Mode
        // Main loop --> process tasks in scheduler queue
        while (TRUE)
        {
 
            // If en event has occured in Low Power Mode, this is handled immediately
            if (PendingEvent == TRUE)
            {
                PendingEvent = FALSE;
                (void)RxdLowHandling();
            }
            (void)TJA1145_GetOpMode(&pmod);
            EventHandling();
 
 
            MotorSpeed  = MC_GetMecSpeedAverageMotor1();
            MotorSpeed1 = MC_GetMecSpeedAverageMotor1();
            if ((pmod == CANTRCV_TRCVMODE_NORMAL))
            {
                CAN_SendMotorSpeed(MotorSpeed);
            }
            task = GetNextTask();
            req  = CheckCanRequestSleepMode();
            if (req == 1)
            {
                extern TJA1145FD_CAN_Selective_WakeUp_t TJA1145FD_CPNC_SLEEP;
                sleep_reqed = 1;
                task        = CHANGE_TO_SLEEP;
                TJA1145FD_CPNC_SLEEP = TJA1145FD_CPNC_CAN_SELECTIVE_WAKEUP_ENABLE;
            }
            if ((sleep_reqed == 0) && (pmod != CANTRCV_TRCVMODE_NORMAL))
            {
                task = CHANGE_TO_NORMAL;
            }
            switch (task)
            {
                case CHANGE_TO_SLEEP:
                   /* inside this function we put the TJA1145 into sleep mode and then put the mcu in STOP mode using the McuEnterStopMode*/
                    (void)ChangeToSleepOperation();
                   
                    sleep_reqed = 0;
                    break;
 
                case CHANGE_TO_STANDBY:
                    (void)ChangeToStandbyOperation();
                    break;
 
                case CHANGE_TO_NORMAL:
                    (void)ChangeToNormalOperation();
                    break;
 
                case EVENT_HANDLING:
                    (void)EventHandling();
                    break;
 
                case POLL_TRCV_STATUS:
                    (void)PollTransceiverStatus();
                    break;
 
                case PORT_SUPERVISION:
                    (void)PortSupervisor();
                    break;
 
                case POLL_WAKE:
                    (void)WakeSupervisor();
                    break;
 
                case CFG_PARTIAL_NETWORKING:
                    (void)ConfigurePartialNetworking();
                    break;
 
                default:
                    break;
            }
            HAL_Delay(5);
        }
    }
 
}

What we notice is that after the wake up from stop mode, the motor status somehow seems normal, but it will take about 2 seconds to start the motor, you can ref to below picture,

The motor status change from, 16-18-4-6, and after the status changed to 6, it takes about 2 seconds to start the motor, and in normal status, means we do not have the wakeup, it takes about less 100ms to start the motor.

Not sure why it takes so long to start the motor, and as we want to evalute the response time of this low power mode, this 2 seconds is somehow critical for us.

Appreciate for your comments, thanks.

0693W00000UoEHQQA3.jpg

0 REPLIES 0