简体   繁体   English

如何从睡眠模式唤醒Pic32?

[英]How to wake Pic32 from sleep mode?

I am trying to keep PIC32 in sleep mode on boot up. 我试图在启动时将PIC32保持在睡眠模式。 And when the power button is pressed the Pic32 should exit the sleep mode and wake up. 当按下电源按钮时,Pic32应该退出睡眠模式并唤醒。

I am able to put PIC32 in sleep mode but I am not sure how I can trigger it to wake up on button press. 我能够将PIC32置于睡眠模式,但是我不确定如何在按下按钮时将其唤醒。 Is it possible if I can trigger an interrupt whenever the user presses the power button and thus wake the PIC32? 每当用户按下电源按钮从而唤醒PIC32时,是否可以触发中断? I am using microchip harmony framework and am quite new to this can someone please suggest how I can achieve this? 我正在使用微芯片协调框架,对此还很陌生,有人可以建议我如何实现这一目标吗?

To put PIC32 I am using the PowerEnterMode function of harmony. 为了放置PIC32,我使用了和谐的PowerEnterMode函数。 To wake up PIC32 I have tried using the watch dog timer following the sample project provided with microchip harmony but couldn't get it to work. 为了唤醒PIC32,我尝试在芯片和谐提供的示例项目之后使用看门狗定时器,但无法使其正常工作。 I also read that I can use external interrupt to set it up but I don't know how to set it up. 我还读到我可以使用外部中断来设置它,但是我不知道如何设置它。

I have added my code below. 我在下面添加了我的代码。

void APP_Initialize ( void )
{
    DRV_ADC_Open();
    DRV_ADC_Start();
    PLIB_ADC_Enable(ADC_ID_1);

    SPIHandle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE );
    DelayMs(100);
    SYS_DEVCON_PowerModeEnter(SYS_POWER_MODE_IDLE);

    appData.state = APP_STATE_POWER_UP;    
}

void APP_Tasks (void)
{
    switch ( appData.state )
    {
        case APP_STATE_POWER_UP:
             {
                 uint8_t pwrButton;
                 pwrButton = PWR_BTNStateGet() ;   
                 if (npwrButton == 0)                  // If button is pressed
                 {
                     PwrButtonDebounce += 1;      // Increment the pressed timer
                     DelayMs(10);
                 } else
                 {
                     PwrButtonDebounce = 0;            // Clear the Debounce Timer  
                 }
                 if (PwrButtonDebounce == MAX_DEBOUNCE)     // Debounced....
                 {
                     // Here Wake up routine on button press 
                     appData.state = APP_STATE_INIT;
                 }
             }
    }

I expect that whenever I press the power button the Pic32 should come in the APP_STATE_POWER_UP state and on debounce go in the initialization state but It never comes in this state. 我希望每当我按下电源按钮时,Pic32都将进入APP_STATE_POWER_UP状态,并且在反跳时进入初始化状态,但它永远不会进入此状态。 Can someone suggest how I can set this up? 有人可以建议我如何设置吗?

You should use Change Notification interrupt. 您应该使用更改通知中断。

Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed. 在您具有按钮的引脚上启用CN​​中断,按下该中断将唤醒您的设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM