This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

delay in zstack event

Hi friends, 

I am using zstack sample application in msp430 experimental board. 

I have kept end device in PM2 mode. 

Process:

when I press SW1, End device will send temperature sensor value to coordinator.  

I have tested this with normal mode and it works fine. Because polling concept used for keys(100ms). 

But In low power mode, we enable interrupt for keys. when I press SW1 the reading and sending process doesn't occur immediately. There is some delay in process start. 

What is the reason for that?

Regards,

Keerthi G

 

  • Do you try to use interrupt for key trigger?

  • Hi YiKai Chen,

    I have done only below changes. 

    I have changed onboard.c as in Power management documents. 

    else // !OB_COLD
    {
    /* Initialize Key stuff */
    HalKeyConfig(HAL_KEY_INTERRUPT_ENABLE, OnBoard_KeyCallback); 
    }

     

    I have put a break point in key int ISR.

    If I press SW1, Execution will come to below key ISR. 

    INTERRUPT_KEYBD()
    {
    #if (HAL_KEY == TRUE)

    #ifdef POWER_SAVING
    /* Must allow key interrupt to cancel sleep */
    __low_power_mode_off_on_exit();
    #endif

    /* Read the key before it gone */
    HAL_KEY_INT_KEYS(halIntKeys);

    /* Clear depending interrupt */
    HAL_CLEAR_KEY_INT();

    /* A key is pressed, let HalKeyPoll routing handle the keys at a later time */
    osal_start_timerEx( Hal_TaskID, HAL_KEY_EVENT, 10000);
    #endif /* HAL_KEY */
    }

    Did you ask this or something else? 

    Regards,

    Keerthi G.

  • Yes, that's what I am asking. Do you try to reduce 10000 in osal_start_timerEx( Hal_TaskID, HAL_KEY_EVENT, 10000)  to see if it response faster.

  • Hi YiKai Chen,

    Yes. Now Thats working fine. Thanks. 

    I have another doubt. I have enabled the RTC. For each 5 min, I have send some data to coordinator. 

    RTC ISR:

    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    {
    switch(__even_in_range(RTCIV,16))
    {
    case RTC_NONE: // No interrupts
    break;

    case RTC_RTCRDYIFG: // RTCRDYIFG
    break;

    case RTC_RTCTEVIFG: // RTCEVIFG
    HAL_TOGGLE_STATLED3();
    Sample_Min++;
    if(Sample_Min == 5)
    {
    Sample_Min = 0;
    osal_set_event(SampleApp_TaskID, READ_EVT);
    __bic_SR_register_on_exit(LPM3_bits);
    }

    break;

    Here also I get a delayed response for READ_EVT occurrence. 

    I think problem in hal_sleep function. 

     

    /* set MSP430 power mode, global interrupt will be enabled in the macro */
    HAL_SLEEP_SET_POWER_MODE(halPwrMgtMode);
    /* wake up from sleep in ISR */

    HAL_SLEEP_DISABLE_INTERRUPTS();

    /* disable sleep timer interrupt */
    HAL_SLEEP_TIMER_DISABLE_INT();

    if (timeout != 0)
    {
    /* Calculate timer elapsed only if timer sleep */
    halAccumulatedSleepTime += halMacTimerElapsed( &timeout );
    }
    else
    {
    /* Restart timer */
    HAL_MAC_SLEEP_TIMER_RESTART();
    }

    /* Process keyboard "wake-up" interrupt, exit while loop if key interrupt */
    if ( HalKeyExitSleep() || timeout == 0 )
    {
    break;
    }

    They do some exit sleep using key interrupt. 

    How Can I do this things for RTC or any other interrupt? 

    I have gone through the HalKeyExitSleep() . But I can't follow. 

    if I am telling correct problem, Please explain. 

     

     

    Regards,

    Keerthi G

     

     

  • Try to replace __bic_SR_register_on_exit(LPM3_bits); in case RTC_RTCTEVIFG: with

    #ifdef POWER_SAVING
    /* Must allow key interrupt to cancel sleep */
    __low_power_mode_off_on_exit();
    #endif

     

  • Hi YiKai Chen, 

    I was changed. But The problem is same. 

    /* Process keyboard "wake-up" interrupt, exit while loop if key interrupt */
    if ( HalKeyExitSleep() || timeout == 0 )
    {
    break;
    }

    I think we need to exit from while loop in hal_sleep function. 

    And Need to add HalRTCExitSleep() like below. I don't write any coding for HalRTCExitSleep function. 

    If I am telling right , you will tell how to write that function. 

    /* Process keyboard "wake-up" interrupt, exit while loop if key interrupt */
    if ( HalKeyExitSleep() || timeout == 0 || HalRTCExitSleep() )
    {
    break;
    }

    Another question:

    What is timeout in above if statement?

    Regards,

    Keerthi G

  • I suppose my suggestion should work. Can you show me what's revision you made in __interrupt void RTC_ISR(void)?

  • Hi YiKai Chen,

    This is RTC ISR. This function present in sampleapp.c. 

    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    {
    switch(__even_in_range(RTCIV,16))
    {
    case RTC_NONE: // No interrupts
    break;

    case RTC_RTCRDYIFG: // RTCRDYIFG
    break;

    case RTC_RTCTEVIFG: // RTCEVIFG
    HAL_TOGGLE_STATLED3();
    Sample_Min++;
    if(Sample_Min == 05)
    {
    Sample_Min= 0;
    osal_set_event(SampleApp_TaskID, READ_EVT);

    #ifdef POWER_SAVING
    /* Must allow key interrupt to cancel sleep */
    __low_power_mode_off_on_exit();
    #endif

    }

    break;
    case RTC_RTCAIFG: // RTCAIFG
    break;
    case RTC_RT0PSIFG: // RT0PSIFG
    break;
    case RTC_RT1PSIFG: // RT1PSIFG
    break;
    case 12: break; // Reserved
    case 14: break; // Reserved
    case 16: break; // Reserved
    default: break;
    }
    }

    Note:

    Then Why do they using HalKeyExitSleep(). ?

    Regards,

    Keerthi G

  • Hi YiKai Chen, 

    Again the problem in key interrupt also. 

    -DPOLL_RATE=5000 - No delay

    -DPOLL_RATE=10000 - Small amount delay to trigger the event

    -DPOLL_RATE=60000 - More delay to trigger the event

    Regards,

    Keerthi G