KL27 can wakeup by Port C pin 3 to 7, but not 1 and 2

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

KL27 can wakeup by Port C pin 3 to 7, but not 1 and 2

跳至解决方案
1,124 次查看
gsmgbl
Contributor IV

Hi,

I am using KL27 and implement my code on IAR workbench with freertos, then a stranger thing happened that is my device can be wakeup interrupt by the port C from pin 3 to pin 7, but pin 1 and pin 2 are not responding. All these 7 pins are configured as GPIO and connected to either push switches and slide switches. I measured the current and my device is successfully entered into normal stop mode, even I tried to configure some pin that cannot wakeup the device, that still works fine. But pin 1 and pin 2 are not under my configuration. In addition, I also tried with my development board, the function works fine. Not sure if I miss or make something wrong. Please see my code below and kindly advise.

Thank you.

Gilbert

void APP_STOPmode()                  // Stop mode entry
{
    f_LOW_POWER = true;
    vTaskSuspendAll();
    APP_SetWakeupConfig();
    SMC_SetPowerModeStop(SMC, kSMC_PartialStop);
}

void APP_SetWakeupConfig()        // Wakeup pin configuration
{
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC1_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC2_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC3_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC4_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC5_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC6_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC7_GPIO_PIN, kPORT_InterruptEitherEdge);
}

void APP_PostSleepConfig()           // Pin usage configuration after wakeup
{
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC1_GPIO_PIN, kPORT_InterruptEitherEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC2_GPIO_PIN, kPORT_InterruptOrDMADisabled);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC3_GPIO_PIN, kPORT_InterruptFallingEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC4_GPIO_PIN, kPORT_InterruptFallingEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC5_GPIO_PIN, kPORT_InterruptFallingEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC6_GPIO_PIN, kPORT_InterruptFallingEdge);
    PORT_SetPinInterruptConfig(BOARD_PTC_PORT, BOARD_PTC7_GPIO_PIN, kPORT_InterruptEitherEdge);
}

 if (f_LOW_POWER)                        // Wakeup point
{
    SMC_SetPowerModeRun(SMC);
    APP_PostSleepConfig();
    xTaskResumeAll();
    f_LOW_POWER = false;
}

标签 (1)
1 解答
905 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gilbert,

   Thanks for your information update and tell me the problem is solved.

    Yes, as you know the stop can be waked up by the interrupt.

    If the other interrupt happens during the STOP mode entering, it will cause the low power mode entry failed, so to make sure the low power successful entry, you must disable all the other interrupt, except the wake up source.

   Now, if you still have question about it, just let me know, If your question is solved, please help to mark the correct answer to close this question, thanks a lot, and have a nice day!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

3 回复数
905 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gilbert Liu,

   About PTC1, PTC2 wake up question, please refer to our KSDK2.2_FRDM-KL27 code at first.

  This code when enter STOP mode, it can be waked up by the PTC1, I have test it on my side, it works ok.

   Please check the official code at first.

   You can download the code from this link:

Welcome to MCUXpresso | MCUXpresso Config Tools 

  Click SDK builder, then choose board as FRDM-KL27, generate the code and download it.

If you still have question after you refer to the official code, please kindle let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
905 次查看
gsmgbl
Contributor IV

Hi Kerry,

Thank you for your recommendation.

In fact, I fixed my problem by adding "portDISABLE_INTERRUPTS();" before I suspend all other tasks and go to sleep mode. I think my device didn't go to sleep mode properly after I changed my functions, so it couldn't wakeup from sleep mode. After disable the interrupts on the freertos, then my device went into sleep mode and I can wake it up properly now. Thanks again.

Regards,

Gilbert

0 项奖励
回复
906 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Gilbert,

   Thanks for your information update and tell me the problem is solved.

    Yes, as you know the stop can be waked up by the interrupt.

    If the other interrupt happens during the STOP mode entering, it will cause the low power mode entry failed, so to make sure the low power successful entry, you must disable all the other interrupt, except the wake up source.

   Now, if you still have question about it, just let me know, If your question is solved, please help to mark the correct answer to close this question, thanks a lot, and have a nice day!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------