This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9E5 RTC & GPIO Wake Up...

Hello ,

This nRF9E5 wake up function is driving me slowly nuts...

How to distinguish whether the wake up is coming from RTC or from GPIO.

I have tried to read the wakeup status from RWSTA0, BIT8 RTC timer status and BITS 7-0 for pins P07-P00 but it seems to be so that GPIO pin wake up will always set the RTC bit too.

While(REGX_CTRL & 0x10);             // Wait until register not busy

REGX_CTRL = 0x04;                        // Bits 0,1,2, Address '100' = RWSTA0  Bit4 '0' read

While(REGX_CTRL & 0x10);             // Wait until register not busy

iWakeUpStatus   = ((((unsigned int)REGX_MSB  << 8)  & 0x0100);

iWakeUpStatus  |=    ((unsigned int)REGX_LSB             & 0x0018);     // Bit3 P03,  Bit4 P04,  Bit8 RTC

Parents
  • There have been no update to the nRF9E5 for the last 12-15years, so I doubt we can prioritize investigation on this specific request. I did find an old example, unfortunately it only show how to setup wakeup on RTC and pin, not check the actual reset source. However maybe it still can be useful for others.

     
    
    /*=====================================================
    *
    * Copyright (C) 2006 Nordic Semiconductor
    *
    * This is distributed in the hope that it will be useful, but WITHOUT
    * WARRANTY OF ANY KIND.
    *
    * Author(s): KME 
    *
    * DESCRIPTION: Powerdown and wakeup demonstration.
    * Powerdown start on press on P01 (SW1).
    * Wakeup after 3s or on press on P03 (SW2).
    * Blink all LED 2 times on wakeup.
    *
    *====================================================*/
    
    #include <Nordic\reg9e5.h>
    
    void init(void)
    {
    IE |= 0x80; 
    // Table 37 IE Register – SFR 0xA8 
    // Enables interrupt
    EIE |= 0x10; 
    // Table 41 EIE Register – SFR 0xE8 
    // Enables wakeup interrupt.
    P0_ALT = 0x00;
    P0_DIR = 0xAA;
    }
    
    void delay(volatile unsigned char n)
    {
    unsigned char i;
    while(n--)
    for(i=0;i<175;i++)
    ;
    }
    
    void wakeup_blink(void)
    {
    P0 &= 0xAA; 
    delay(250);
    P0 |= 0x55; 
    delay(250); 
    P0 &= 0xAA; 
    delay(250);
    P0 |= 0x55;
    // Blink all LED 2 times on wakeup
    }
    
    void powerdown(void)
    {
    // This part will initialize wakeup after 3s
    TICK_DV = 0x03; // Init value -> 1ms tick
    while(REGX_CTRL & 0x10) // Wait until not busy
    ;
    REGX_MSB=0x00;
    REGX_LSB=0x00;
    REGX_CTRL=0x09; // Address 1001b -> WGTIMER
    while(REGX_CTRL & 0x10)
    ; 
    REGX_MSB=0x0B;
    REGX_LSB=0xB8;
    REGX_CTRL=0x0A; // Address 1010b -> WRTCLAT
    while(REGX_CTRL & 0x10)
    ; 
    
    // This part will initialize wakeup on keypress on P03 (SW2)
    REGX_MSB=0xC0; 
    REGX_LSB=0x00;
    REGX_CTRL=0x0C;
    while(REGX_CTRL & 0x10) 
    ;
    
    CK_CTRL = 0x04; // Enter power down
    }
    
    void main(void)
    {
    init();
    
    while(1)
    { 
    if(P01==0) // Start powerdown if P01 (SW1) is pressed
    {
    while(P01==0)
    ; 
    powerdown(); // Wakeup after 3s or on keypress on P03 (SW2)
    wakeup_blink(); 
    }
    }
    }

  • Thaks for your responce.

    The main problem is that GPIO wakeup also triggers the RTC interrupt. What I like to have is that RTC interrupt lives completely its own life. No RTC interrupt action when GPIO interrupt occurs….

  • Maybe this can be of help:

    /*= rtc.c ======================================================================
     *
     * Copyright (C) 2006 Nordic Semiconductor
     *
     * This file is distributed in the hope that it will be useful, but WITHOUT
     * WARRANTY OF ANY KIND.
     *
     * Author(s): Kenneth Megård
     *
     * DESCRIPTION:
     *
     *   Example of RTC interrupt.
     *
     * COMPILER:
     *
     *   This program has been tested with Keil C51 V7.50.
     *
     * $Revision: 1 $
     *
     *==============================================================================
    */
    #include <Nordic\reg9e5.h>
    
    #define WRTCLAT 0x0A;
    
    static void InitRTC(void)
    {   
    	while ( REGX_CTRL & 0x10);		// Write: Wait until REGX_CRTL.4 == 0 (i.e. not busy) 
    	REGX_MSB = 0x3;					// RTC interrupt every 1 S.
    	REGX_LSB = 0xe8;
    	REGX_CTRL = WRTCLAT;
    
    	while ( REGX_CTRL & 0x10);		// Write: Wait until REGX_CRTL.4 == 0 (i.e. not busy) 
    
    	EWDI = 1;						// Enable the RTC timer interrupt.
    }
    
    void RTCISR (void) interrupt 12
    {
    	P0 ^= 0x01;						// Toggle LED.
    	WDTI = 0;						// Clear the RTC interrupt.
    }
    
    void Init(void)
    {
    	P0_DIR = 0x20;					// P0.5 is an input, the rest are outputs.
    
    	InitRTC();
    	EA = 1;							// Enable Interrupts.
    }
    
    void main(void)
    {
    	Init();
    
    	while(1);
    }

Reply
  • Maybe this can be of help:

    /*= rtc.c ======================================================================
     *
     * Copyright (C) 2006 Nordic Semiconductor
     *
     * This file is distributed in the hope that it will be useful, but WITHOUT
     * WARRANTY OF ANY KIND.
     *
     * Author(s): Kenneth Megård
     *
     * DESCRIPTION:
     *
     *   Example of RTC interrupt.
     *
     * COMPILER:
     *
     *   This program has been tested with Keil C51 V7.50.
     *
     * $Revision: 1 $
     *
     *==============================================================================
    */
    #include <Nordic\reg9e5.h>
    
    #define WRTCLAT 0x0A;
    
    static void InitRTC(void)
    {   
    	while ( REGX_CTRL & 0x10);		// Write: Wait until REGX_CRTL.4 == 0 (i.e. not busy) 
    	REGX_MSB = 0x3;					// RTC interrupt every 1 S.
    	REGX_LSB = 0xe8;
    	REGX_CTRL = WRTCLAT;
    
    	while ( REGX_CTRL & 0x10);		// Write: Wait until REGX_CRTL.4 == 0 (i.e. not busy) 
    
    	EWDI = 1;						// Enable the RTC timer interrupt.
    }
    
    void RTCISR (void) interrupt 12
    {
    	P0 ^= 0x01;						// Toggle LED.
    	WDTI = 0;						// Clear the RTC interrupt.
    }
    
    void Init(void)
    {
    	P0_DIR = 0x20;					// P0.5 is an input, the rest are outputs.
    
    	InitRTC();
    	EA = 1;							// Enable Interrupts.
    }
    
    void main(void)
    {
    	Init();
    
    	while(1);
    }

Children
Related