RTC can not wakeup BF518 from deepsleep

Hi, can anybody help me the question, rtc interrupt run fine, but rtc can not wakeup bf518 from deepsleep.

void Set_RTC(void)
{

    *pRTC_PREN = 1;
    /* wait for writes to complete */
    while ((*pRTC_ISTAT&0x8000)==0);


    *pRTC_SWCNT = 1;
    /* wait for writes to complete */
    while ((*pRTC_ISTAT&0x8000)==0);

    *pRTC_ICTL = 0x0001;
    /* wait for writes to complete */
    while ((*pRTC_ISTAT&0x8000)==0);


}


void sleep(void)
{
    ADI_SYSCTRL_VALUES sleep;

    Set_RTC();

    bfrom_SysControl(SYSCTRL_EXTVOLTAGE | SYSCTRL_PLLCTL | SYSCTRL_READ, &sleep, NULL);
    sleep.uwPllCtl |= STOPCK; /* either: Sleep Mode */
    sleep.uwPllCtl |= PDWN; /* or: Deep Sleep Mode */
    bfrom_SysControl(SYSCTRL_WRITE | SYSCTRL_EXTVOLTAGE | SYSCTRL_PLLCTL, &sleep, NULL);

    return;
}


void Init_RTC_Interrupts(void)
{

    *pSIC_IAR1 &= 0xf0ffffff;
    *pSIC_IAR1 |= 0x01000000;

    register_handler(ik_ivg8, RTC_ISR);

    *pSIC_IMASK0 &= 0xffff0fff;
    *pSIC_IMASK0 |= 0x00004000;


    *pSIC_IWR &= 0xffff0fff;
    *pSIC_IWR |= 0x00004000;


}


EX_INTERRUPT_HANDLER(RTC_ISR)

{

    ADI_SYSCTRL_VALUES active;

    //Led_on();

    //*pPLL_CTL &= ~(BYPASS|PLL_OFF|STOPCK|PDWN);
    //bfrom_SysControl(SYSCTRL_EXTVOLTAGE | SYSCTRL_PLLCTL | SYSCTRL_READ, &active, NULL);
    //active.uwPllCtl &= ~(BYPASS|PLL_OFF|STOPCK|PDWN); /* or: Deep Sleep Mode */
    //bfrom_SysControl(SYSCTRL_WRITE | SYSCTRL_EXTVOLTAGE | SYSCTRL_PLLCTL, &active, NULL);

    //asm ("IDLE;");


    *pRTC_ISTAT = 0x807f;
    /* wait for writes to complete */
    while ((*pRTC_ISTAT&0x8000)==1);

    *pRTC_ICTL = 0x0000;
    /* wait for writes to complete */
    while ((*pRTC_ISTAT&0x8000)==0);

}


void main(void)
{

    Set_PLL(4,1);

    Init_Led();
    Init_RTC_Interrupts();

    sleep();

    Led_on();

    while(1)
    {
        asm ("nop;");

    }
}



add the code.
[edited by: zf_zhai at 2:41 AM (GMT 0) on 28 Apr 2019]
  • Hello ,

    As a quick check, why do you have sleep and deepsleep mode in same code itself. Please note that both of them hadn't have the identical procedures to falling and wake up the processor.

    So could you please make sure in your code that you have properly followed procedures accoding to the (deepsleep/sleep/wakeup) modes which is provided in the "Programming Model" section and Table 24-2. "RTC System State Transition Events (PageNo:1199/1524)"  of Hardware reference manual.

    Also you would find the exmple "RTC Stopwatch For Exiting Deep Sleep Mode (PageNo:1205/1524)" in the "Programming Example" section in the RTC chapter of Hardware reference manual.

    www.analog.com/.../ADSP-BF51x_hwr_rev1.2.pdf

    Regards,
    Lalitha