Hi,
I am working on LPC824, after wake-up from Deep-sleep mode a system reset is required. Can anybody tell me how to get normal function without system reset?
Below is my code:
void Setup_Low_Power_Mode(void)
{
// Power down the BOD and ACMP_PD since we are not using it
LPC_SYSCON->PDSLEEPCFG |= (BOD_PD | ACMP_PD | ADC_PD | WDTOSC_PD | SYSOSC_PD);
// Turn clocks off to unused peripherals (Leave UART0, UART2 on!)
LPC_SYSCON->SYSAHBCLKCTRL &= ~(UART0 | UART1 | UART2 | ADC | ACMP | SCT | IOCON | MRT | DMA | SWM
| MTB | I2C0 | I2C3 | I2C2 | I2C1 | WWDT | CRC | SPI1 | SPI0);
/* 10KHz clock source */
LPC_WKT->CTRL |= 1; /* using Low Power clock 10kHz */
/* Setup for wakeup in timeout */
LPC_WKT->COUNT = (10000 * 2); /* 10KHz * 2S */
/* 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 */
LPC_SYSCON->PDAWAKECFG &= ~(BOD_PD | SYSPLL_PD | IRCOUT_PD | IRC_PD | FLASH_PD | ADC_PD | SYSOSC_PD | WDTOSC_PD | ACMP_PD);
LPC_SYSCON->STARTERP1 = 1<<15; /* WKT interrupt */
LPC_SYSCON->MAINCLKSEL = 0<<0;
// PCON = 1 selects Deep-sleep mode
LPC_PMU->PCON = 0x1;
// Set the SleepDeep bit
SCB->SCR |= (1<<2);
// Wait here for wake up command.
__WFI();
}
void Config_WKT(void)
{
/* Alarm/wake timer as chip wakeup source */
LPC_SYSCON->STARTERP1 = (1 << 15) | (LPC_SYSCON->STARTERP0 & (0xff));
/* Enable and reset WKT clock */
LPC_SYSCON->SYSAHBCLKCTRL = (1 << 9) | (LPC_SYSCON->SYSAHBCLKCTRL & ~(0xda100000));
LPC_SYSCON->PRESETCTRL &= ~((1 << (uint32_t) 9) | 0xfffe2000);
LPC_SYSCON->PRESETCTRL = (1 << (uint32_t) 9) | (LPC_SYSCON->PRESETCTRL & ~0xfffe2000);
/* Disable wakeup pad */
/** Disable the Wake-up */
/** Enable the low-power oscillator in deep power-down*/
LPC_PMU->DPDCTRL &= ~((1 << 1) | (1 << 3) | (~0xf));
/* Disable wakeup hysteresis by setting the bit (set to disable),
enable 10KHz oscillator for all power down modes including deep
power-down */
/** Enable wake-up pin hysteresis */
/** Enable the low-power oscillator (10 khz self wk) */
/** Enable the low-power oscillator in deep power-down*/
LPC_PMU->DPDCTRL = ((1 << 0) | (1 << 2) | (1 << 3) | (LPC_PMU->DPDCTRL & ~(~0xf)));
/* Enable WKT interrupt */
NVIC_EnableIRQ(WKT_IRQn);
}
void WKT_IRQHandler(void)
{
/* Clear WKT interrupt request */
LPC_WKT->CTRL = ((uint32_t) (1 << 1)) /*!< Wake-up or alarm timer flag */
| (LPC_WKT->CTRL & (7));
/*!< Clears the self wake-up timer */
LPC_WKT->CTRL = ((uint32_t) (1 << 2)) /*!< Clear and stop WKT counter */
| (LPC_WKT->CTRL & (7));
LPC_SYSCON->SYSAHBCLKCTRL |= (UART2 | GPIO | ADC | ACMP | SCT | IOCON | MRT | DMA);
NVIC_SystemReset();
return;
}
Hi Ranjith Shanbhag,
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jeremyzhou,
Thanks for your reply. There was some state machine problem. I am able to solve it without system reset.
i am waking up the controller with 2 different peripherals. one with wake up timer and another with Pin interrupt.
Since Synchronous slave mode we unable to do, UART Rx pin will be configured as port interrupt before entering into sleep and waking up with Receive command. Here without system reset unable to drive normal function after waking up.
Please provide me your thoughts.
Thanks in advance.!!
below is my code to for port interrupt configuration and IRQ handler code:
void Wakeup_interrupt_configuration(void)
{
// Configure P0.0 as PININT7, falling edge sensitive
LPC_PIN_INT->IST = 0xFF; // Clear any pending edge-detect interrupt flags
LPC_SYSCON->PINTSEL[7] = 0; // P0.0 assigned to PININT7
LPC_PIN_INT->ISEL = 0x0; // Edge-sensitive
LPC_PIN_INT->SIENF = 1<<7; // Falling-edge interrupt enabled on PININT7
// Configure PININT7 as wake up interrupt in SysCon block
LPC_SYSCON->STARTERP0 = 1<<7;
__disable_irq();
NVIC_SetPriority (PININT7_IRQn, 11);
// Enable pin interrupts 0 - 1 in the NVIC
NVIC_EnableIRQ(PININT7_IRQn);
__enable_irq();
}
void PININT7_IRQHandler(void)
{
// Clear the pin interrupt, and any other irrelevant edge-detect flags
LPC_PIN_INT->IST = 0xFF;
// Clear the SleepDeep bit
SCB->SCR &= ~(1<<2);
// PCON = 0 selects active mode
LPC_PMU->PCON = 0x0;
/* Disable 10KHz clock source */
LPC_WKT->CTRL |= 0; /* using Low Power clock 10kHz */
/** Disable the low-power oscillator (10 khz self wk) */
LPC_PMU->DPDCTRL = ((0 << 2)| (LPC_PMU->DPDCTRL & ~(~0xf)));
/*!< Clears the self wake-up timer */
LPC_WKT->CTRL = ((uint32_t) (1 << 2)) /*!< Clear and stop WKT counter */
| (LPC_WKT->CTRL & (7));
NVIC_SystemReset();
Config_ESI_UART();
// Activate clocks to the needed peripherals for normal mode if they are off, UART0 and SWM are activated inConfig_ESI_UART()
LPC_SYSCON->SYSAHBCLKCTRL |= (UART2 | GPIO | ADC | ACMP | SCT | IOCON | MRT | DMA);
Dimming_initialise();
Sleep_Active_initialise();
LPM_Enabled = FALSE;
return;
}
Hi Ranjith Shanbhag,
Thanks for your reply.
To synchronize with the slave target, you needn't to reset MCU as the MCU will reboot.
I'd like to suggest that you can configure the USART be able to wake up the system form sleep mode in asynchronous or synchronous mode on any enabled USART interrupt.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jeremyzhou,
Thanks for your support.
Start bit has been received in asynchronous mode this will wake up from sleep mode?
Hi Ranjith Shanbhag,
Thanks for your reply.
1) Start bit has been received in asynchronous mode this will wake up from sleep mode?
Yes, as the Fig 1 demonstrates.
Fig 1
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi jeremyzhou,
Can you tell me how to configure start bit event as a wake up call?
Hi Ranjith Shanbhag,
Thanks for your reply.
I think the last reply had already exemplified the sequence of configuring the interrupt to wake up from the deep-sleep mode.
The Table 179 demonstrates the various enable bits of USART interrupt sources, you can the STARTEN, When it become 1, enables an interrupt when a framing error has been detected.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
No.
The last post explains how to use the USART to wake up the part from deep sleep when using SYNCHRONOUS comms reception. In deep sleep, the USART has no clock so it cannot receive a start bit in ASYNCHRONOUS reception, which is what the OP is asking. The quotation from the manual spells it out very clearly by saying "you must connect the SCLK function..."
I am struggling with the same issue, and I'm now trying to get PININT on PIO0_0 to bring me out of deep sleep. I may then choose power-down mode instead because I can still allegedly wake up from power-down using PININT.