Questions:AT32F405 OTGHS作为device,在AT32F405准备进入deepsleep模式过程中,如果此时拔掉USB线有概率导致OTGHS_WKUP不能唤醒deepsleep模式,并且功耗高于正常deepsleep模式功耗,如何解决此问题? Answer: 如果正好在判断挂起状态suspend flag有效到pwc_deep_sleep_mode_enter()函数中间拔掉USB线,并且拔掉USB线过程中USB接口发生多次断开——接触情况,USB PHY会退出挂起状态,此时进入deepsleep模式,就会导致后续OTGHS_WKUP不能唤醒deepsleep模式。因USB PHY在工作状态,功耗也会比正常进入deepsleep模式功耗高。 解决方法,判断挂起状态suspend flag有效后,先关闭总中断(__disable_irq();),然后判断OTGHS电源和时钟门控寄存器中PHY挂起状态位有效和设备状态寄存器中挂起状态有效,再进入deepsleep模式。 修改方式参考如下红色部分: if(((mouse_type*)(otg_core_struct.dev.class_handler->pdata))->hid_suspend_flag == 1) { __disable_irq(); if(OTG_PCGCCTL(otg_core_struct.usb_reg)->pcgcctl_bit.suspendm == 1 &&usb_suspend_status_get(otg_core_struct.usb_reg) == 1) { #ifdef USB_OTG_HS otg_core_struct.usb_reg->gccfg_bit.wait_clk_rcv= TRUE; #endif /* congfig the voltage regulator mode */ pwc_voltage_regulate_set(PWC_REGULATOR_EXTRA_LOW_POWER); /* enter deep sleep mode */ pwc_deep_sleep_mode_enter(PWC_DEEP_SLEEP_ENTER_WFI); /* wait clock stable */ delay_us(120); system_clock_recover(); //((mouse_type*)(otg_core_struct.dev.class_handler->pdata))->hid_suspend_flag = 0; #ifdef USB_OTG_HS otg_core_struct.usb_reg->gccfg_bit.wait_clk_rcv= FALSE; delay_ms(2); usb_open_phy_clk(otg_core_struct.usb_reg); #endif } ((mouse_type *)(otg_core_struct.dev.class_handler->pdata))->hid_suspend_flag= 0; __enable_irq(); }
|