在线时间115 小时
UID3469754
注册时间2018-4-13
NXP金币0
TA的每日心情 | 郁闷 2021-6-16 01:35 |
---|
签到天数: 521 天 连续签到: 1 天 [LV.9]以坛为家II
金牌会员
 
- 积分
- 1783
- 最后登录
- 2021-6-16
|
請問一下網路上的高手
在Deep Sleep mode 要如何使用Pin Interrupt來Wakeup系統?
我把PIO1.0接GND但沒辨法喚醒MCU,不知代碼哪里有錯誤,麻煩各位
高手指導一下,謝謝~
我的代碼功能如下:
先設定好Pin Interrupt PIO1.0參數,進入睡眠前先亮紅燈一段時間,代表參數設定完成
num是設定要進哪一個睡眠模式,進睡眠前會先亮藍燈一段時間才進入睡眠,PIO1.0接到
GND後,系統會醒來,UART0 輸出WAKEUP文字,然後先亮藍燈一段時間進入睡眠
我用的EVB板子是LPCXpresso11U68 OM13058
百度雲盤
https://pan.baidu.com/s/4eSUE526
完整代碼如下:
#include "board.h"
/* Mapped to PIO0_1, ISP_EN button on LPCXpresso board */
#define GPIO_PININT_PIN 0 /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PORT 1 /* GPIO port number mapped to PININT */
#define GPIO_PININT_INDEX 0 /* PININT index used for GPIO mapping */
void PIN_INT0_IRQHandler(void)
{
Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
//Board_LED_Toggle(0);
}
int main(void)
{
uint32_t i,num;
SystemCoreClockUpdate();
Board_Init();
Board_LED_Set(0, 0);
//P1.0 Interrupt Wakeup---------------------------------------------------------------------------------------------
/* We'll use an optional IOCON filter (0) with a divider of 64 for the
input pin to be used for PININT */
Chip_Clock_SetIOCONFiltClockDiv(0, 64);
/* Configure GPIO pin as input */
Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT_PIN);
/* Configure pin as GPIO with pullup and use optional IOCON divider
0 with 3 filter clocks for input filtering */
Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
(IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));
/* Enable PININT clock */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);
/* Configure interrupt channel for the GPIO pin in SysCon block */
Chip_SYSCTL_SetPinInterrupt(GPIO_PININT_INDEX, GPIO_PININT_PORT, GPIO_PININT_PIN);
Chip_SYSCTL_EnableStartPin(0);
/* Configure channel interrupt as edge sensitive and falling edge interrupt */
Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
/* Enable interrupt in the NVIC */
NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
NVIC_EnableIRQ(PIN_INT0_IRQn);
Board_LED_Set(0, 1);
for (i = 0; i < 4000000; i++);
for (i = 0; i < 4000000; i++);
for (i = 0; i < 4000000; i++);
Board_LED_Set(0, 0);
num = 1; //Select sleep mode 0:sleep 1:deep sleep
/* Go to sleep mode - LED will toggle on each wakeup event */
while (1)
{
//sleep LED
Board_LED_Set(2, 1);
for (i = 0; i < 1800000; i++);
Board_LED_Set(2, 0);
switch (num)
{
case 0:
DEBUGOUT("sleep mode\r\n\r\n");
for (i = 0; i < 1800000; i++)
;
Chip_PMU_SleepState(LPC_PMU);
DEBUGOUT("sleep mode-WAKEUP\r\n\r\n");
for (i = 0; i < 1800000; i++)
;
break;
case 1:
DEBUGOUT("Deep Sleep mode\r\n\r\n");
for (i = 0; i < 1800000; i++)
;
/* We can optionally call Chip_SYSCTL_SetDeepSleepPD() to power down the
BOD and WDT if we aren't using them in deep sleep modes. */
Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD | SYSCTL_DEEPSLP_WDTOSC_PD);
/* We should call Chip_SYSCTL_SetWakeup() to setup any peripherals we want
to power back up on wakeup. For this example, we'll power back up the IRC,
FLASH, the system oscillator, and the PLL */
Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD |
SYSCTL_SLPWAKE_FLASH_PD | SYSCTL_SLPWAKE_SYSOSC_PD | SYSCTL_SLPWAKE_SYSPLL_PD));
/* Enter MCU Deep Sleep mode */
Chip_PMU_DeepSleepState(LPC_PMU);
/* Power anything back up here that isn't powered up on wakeup. The example
code below powers back up the BOD and WDT oscillator, which weren't setup to
power up in the Chip_SYSCTL_SetWakeup() function. */
Chip_SYSCTL_SetDeepSleepPD(0);
DEBUGOUT("Deep Sleep mode-WAKEUP\r\n\r\n");
for (i = 0; i < 1800000; i++)
;
break;
}
}
return 0;
}
最佳答案
楼主你好!
你的问题我也复现了,我看到论坛里面你也发了帖子,然后我们的AE也回答了你,并且给了使用Group Int做的代码,你可以参考下,AE的代码我也测了,能够工作,你可以试试。
http://community.nxp.com/thread ...
|
|