Hello Support
I have LPC 54102 board with me and I have tested MCU_Power_Profile. It works fine.
When I press button it comes out of the sleep.
But now when I used the same example to wake up via a GPIO pin it does not work. The ISR is not called.
If I test the interrupt pin separately it works fine.
So no problem in the interrupt configuration.
Can you please tell me if there is any example where the MCU wakes up from an interrupt on GPIO?
Hi Tarun Chaplot,
What the power mode you are entering?
From the user manual, you can get the wake up source for each low power mode:
So, if you enter deep power-down mode, you can't use the pin interrupt to wake up.
Please check you power mode at first.
About the sample code, you can refer to the lpcopen periph_pmu code, which can be downloaded from this link:
LPCOpen Software for LPC5410X|NXP
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Kerry
Were you able to find anything wrong in my code?
Please help on this.
I have configured a GPIO for my SPI interrupt. Whenever I get UDP data the WLAN gives an interrupt.
I want to wake up the host Cortex M4 using the interrupt.
Thanks
Tarun
Hello Kerry
Any update on this?
Thanks
Tarun
Hi Tarun Chaplot,
Really sorry for my later reply!
Yes, I have update.
I have test the LPCXpresso lpc54102 board on our LPC54102 lpcopen code before, it works with PIO0_26 interrupt.
The test project is based on lpcopen which can be download from this link:
http://www.nxp.com/assets/downloads/data/en/software/lpc5410x_xpresso54102_keil_iar_v3.03.000_16.zip
I use the pmu project: lpc5410x_xpresso54102_keil_iar_v3.03.000_16\lpc5410x\examples_5410x\periph_pmu
Modify points:
1.software
The wake up pin to PIO0_26, and comment the RIT wakeup code.
I have attached my pmu.c, you can refer to it. copy this code to folder:lpc5410x_xpresso54102_keil_iar_v3.03.000_16\lpc5410x\examples_5410x\periph_pmu\src
2. Hardware
Add external 100K pull-up resistor in PIO0_26. This is very important!
Then, you can test it directly in the lpcxpresso LPC54102 board.
After the above modification, I can wake up the sleep mode after press pio0_26 to ground, this is the test printf information.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I am using SLEEP mode.
#define PDOWNMODE (POWER_SLEEP)
Yes, I did register the interrupt to NVIC.
/* Enable interrupt in the NVIC */
NVIC_EnableIRQ(PIN_INT0_IRQn);
extern uint8_t flag_wakeup;
void rsi_interrupt_handler(void)
{
DEBUGOUT("Interrupt");
//! Disable the interrupt
rsi_hal_intr_mask();
//Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(INTERRUPT_CHANNEL));
//LPC_SC->EXTINT = EINT0; /* clear interrupt */
flag_wakeup = 1;
//Board_LED_Toggle(1);
//! Set event RX pending from device
rsi_set_event(0);
return;
}
/**
* @file rsi_udp_server.c
* @version 0.1
* @date 15 Aug 2015
*
* Copyright(C) Redpine Signals 2015
* All rights reserved by Redpine Signals.
*
* @section License
* This program should be used on your own responsibility.
* Redpine Signals assumes no responsibility for any losses
* incurred by customers or third parties arising from the use of this file.
*
* @brief : This file contains example application for UDP server socket
*
* @section Description This file contains example application for UDP server socket
*
*
*/
/**
* Include files
* */
//! WiSeMCU board include
#include "board.h"
//! HAL layer
#include "rsi_hal.h"
//! include file to refer data types
#include "rsi_data_types.h"
//! COMMON include file to refer wlan APIs
#include "rsi_common_apis.h"
//! WLAN include file to refer wlan APIs
#include "rsi_wlan_apis.h"
//! socket include file to refer socket APIs
#include "rsi_socket.h"
//! Error include files
#include "rsi_error.h"
//! OS include file to refer OS specific functionality
#include "rsi_os.h"
//! Access point SSID to connect
#define SSID "merci"
//!Scan Channel number , 0 - to scan all channels
#define CHANNEL_NO 0
//! Security type
#define SECURITY_TYPE RSI_OPEN
//! Password
#define PSK ""
//! DHCP mode 1- Enable 0- Disable
#define DHCP_MODE 1
//! If DHCP mode is disabled give IP statically
#if !(DHCP_MODE)
//! IP address of the module
//! E.g: 0x650AA8C0 == 192.168.10.101
#define DEVICE_IP 0x650AA8C0
//! IP address of Gateway
//! E.g: 0x010AA8C0 == 192.168.10.1
#define GATEWAY 0x010AA8C0
//! IP address of netmask
//! E.g: 0x00FFFFFF == 255.255.255.0
#define NETMASK 0x00FFFFFF
#endif
//! local port number
#define DEVICE_PORT 5001
//! Number of packets to send or receive
#define NUMBER_OF_PACKETS 10 //1000
//! Receive data length
#define RECV_BUFFER_SIZE 100
//! Memory length for driver
#define GLOBAL_BUFF_LEN 8000
//! Wlan task priority
#define RSI_WLAN_TASK_PRIORITY 1
//! Wireless driver task priority
#define RSI_DRIVER_TASK_PRIORITY 2
//! Wlan task stack size
#define RSI_WLAN_TASK_STACK_SIZE 500
//! Wireless driver task stack size
#define RSI_DRIVER_TASK_STACK_SIZE 500
//! Memory to initialize driver
uint8_t global_buf[GLOBAL_BUFF_LEN];
uint8_t rsp_buf[18];
#define SERVER_IP_ADDRESS 0x0201A8C0
/* GPIO pin for PININT interrupt */
//#define GPIO_PININT_PIN 26 /* GPIO pin number mapped to PININT */
//#define GPIO_PININT_PORT 0 /* GPIO port number mapped to PININT */
//#define GPIO_PININT_INDEX PININTSELECT0 /* PININT index used for GPIO mapping */
//#define INTERRUPT_IRQ_HANDLER PIN_INT0_IRQHandler /* GPIO interrupt IRQ function name */
//#define PININT_NVIC_NAME PIN_INT0_IRQn /* GPIO interrupt NVIC interrupt name */
/* Select a mode of type 'POWER_MODE_T' for this example: mode available are
POWER_SLEEP, POWER_DEEP_SLEEP, POWER_POWER_DOWN*/
#define PDOWNMODE (POWER_SLEEP)
//#define PDOWNMODE (POWER_POWER_DOWN)
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
/* Saved clock source */
static CHIP_SYSCON_MAINCLKSRC_T saved_clksrc;
uint8_t flag_wakeup;
#if 0
void PININT_IRQ_HANDLER(void)
{
Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
Board_LED_Toggle(0);
}
#endif
typedef struct rsi_ipparams
{
uint8_t mac[6];
uint8_t ip[4];
uint8_t subnet[4];
uint8_t gateway[4];
}rsi_ipparams_t;
rsi_ipparams_t *ptr_st_ip;
int32_t rsi_udp_server()
{
#if 1
int32_t server_socket , client_socket;
struct sockaddr_in server_addr, client_addr;
int32_t status = RSI_SUCCESS;
uint32_t recv_size = 0, packet_count = 0;
int32_t addr_size;
#if !(DHCP_MODE)
uint32_t ip_addr = DEVICE_IP;
uint32_t network_mask = NETMASK;
uint32_t gateway = GATEWAY;
#endif
//! buffer to receive data over UDP server socket
int8_t recv_buffer[RECV_BUFFER_SIZE];
//! Driver initialization
status = rsi_driver_init(global_buf, GLOBAL_BUFF_LEN);
if((status < 0) || (status > GLOBAL_BUFF_LEN))
{
return status;
}
//! RS9113 intialisation
status = rsi_device_init(RSI_LOAD_IMAGE_I_FW);
if(status != RSI_SUCCESS)
{
return status;
}
//! WC initialization
status = rsi_wireless_init(0, 0);
if(status != RSI_SUCCESS)
{
return status;
}
//! Scan for Access points
status = rsi_wlan_scan((int8_t *)SSID, (uint8_t)CHANNEL_NO, NULL, 0);
if(status != RSI_SUCCESS)
{
return status;
}
//! Connect to an Access point
status = rsi_wlan_connect((int8_t *)SSID, SECURITY_TYPE, PSK);
if(status != RSI_SUCCESS)
{
return status;
}
//! Configure IP
#if DHCP_MODE
status = rsi_config_ipaddress(RSI_IP_VERSION_4, RSI_DHCP, 0, 0, 0, rsp_buf,sizeof(rsp_buf),0);
#else
status = rsi_config_ipaddress(RSI_IP_VERSION_4, RSI_STATIC, (uint8_t *)&ip_addr, (uint8_t *)&network_mask, (uint8_t *)&gateway, NULL, 0,0);
#endif
ptr_st_ip = (rsi_ipparams_t *)rsp_buf;
if(status != RSI_SUCCESS)
{
return status;
}
//! Create socket
server_socket = socket(AF_INET, SOCK_DGRAM, 0);
if(server_socket < 0)
{
status = rsi_wlan_get_status();
return status;
}
//! Set server structure
memset(&server_addr, 0, sizeof(server_addr));
//! Set family type
server_addr.sin_family= AF_INET;
//! Set local port number
server_addr.sin_port = htons(DEVICE_PORT);
//! Bind socket
status = bind(server_socket, (struct sockaddr *) &server_addr, sizeof(server_addr));
if(status != RSI_SUCCESS)
{
status = rsi_wlan_get_status();
shutdown(server_socket, 0);
return status;
}
addr_size = sizeof(server_addr);
#endif
#if 1
/* Enable interrupt in the NVIC */
NVIC_EnableIRQ(PIN_INT0_IRQn);
/* Enable wakeup for PININT0 */
Chip_SYSCON_EnableWakeup(SYSCON_STARTER_PINT0);
/* save the clock source, power down the PLL */
saved_clksrc = Chip_Clock_GetMainClockSource();
//LPC_SYSCON->S
while(1){
if(flag_wakeup == 1){
flag_wakeup = 0;
/* Go to sleep mode - LED will toggle on each wakeup event */
//while (1) {
/* Go to sleep state - will wake up automatically on interrupt */
/* Disable PLL, if previously enabled, prior to sleep */
if (saved_clksrc == SYSCON_MAINCLKSRC_PLLOUT) {
Chip_Clock_SetMainClockSource(SYSCON_MAINCLKSRC_IRC);
Chip_SYSCON_PowerDown(SYSCON_PDRUNCFG_PD_SYS_PLL);
}
/* Lower system voltages to current lock (likely IRC) */
Chip_POWER_SetVoltage(POWER_LOW_POWER_MODE, Chip_Clock_GetMainClockRate());
/* Go to sleep leaving SRAM powered during sleep. Use lower
voltage during sleep. */
Board_LED_Toggle(0);
//Chip_POWER_EnterPowerMode(PDOWNMODE,NULL);
Chip_POWER_EnterPowerMode(PDOWNMODE,
(SYSCON_PDRUNCFG_PD_SRAM0A | SYSCON_PDRUNCFG_PD_SRAM0B));
Board_LED_Toggle(1);
}
}
#endif
#if 1
while(packet_count < NUMBER_OF_PACKETS)
{
recv_size = RECV_BUFFER_SIZE;
do
{
//! Receive data on socket
status = recvfrom(server_socket, recv_buffer, recv_size, 0, (struct sockaddr *)&client_addr, &addr_size);
if(status < 0)
{
status = rsi_wlan_get_status();
shutdown(server_socket, 0);
return status;
}
//! subtract received bytes
recv_size -= status;
} while(recv_size > 0);
packet_count++;
}
#endif
return 0;
}
void main_loop(void)
{
while(1)
{
////////////////////////
//! Application code ///
////////////////////////
//! event loop
rsi_wireless_driver_task();
}
}
int main()
{
int32_t status;
//! Board Initialization
SystemCoreClockUpdate();
Board_Init();
//SysTick_Config(SystemCoreClock / 1000);
//! WiFi SPI init
status = rsi_mcu_spi_init();
if(status == 0)
{
//! Call UDP server application
status = rsi_udp_server();
//while(1);
}
//! Application main loop
main_loop();
return status;
}
To add to my last update if I put a breakpoint in ISR this hits the ISR. So I believe hardware interrupt works fine.