sleep_mode() power down breaks RF Communication

Discussion in 'Microcontrollers and Programming' started by Uma Maheswary, Dec 14, 2016.

  1. Uma Maheswary

    Uma Maheswary

    Joined:
    Dec 14, 2016
    Messages:
    2
    Likes Received:
    0
    Hi
    I could run the LWmesh peer to peer application for my atmega256rfr2 devices.http://www.atmel.com/tools/lightweight_mesh.aspx.Now I modified the code for reducing power consumption in rf devices.The modified code for sending device is as follows
    Code:
    volatile int lastPIRsensorState=1;
    volatile int PIRsensorState=0;
    void Hibernate(){
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    ADCSRA&=~(1<<7);
    sleep_enable();
    EICRA|=(1<<ISC00);
    EIMSK|=(1<<INT0);
    sei();
    sleep_disable();
    EIMSK&=~(1<<INT0);
    cli();
    }
    ISR(INT0_vect){
    PIRsensorState=!lastPIRsensorState;
    }
    static void appDataConf(NWK_DataReq_t *req){
    appDataReqBusy=false;
    (void)req;
    }
    static void appSendData(void){
    
    if (appDataReqBusy)
        return;
    
     
      appDataReqBuffer[0]=PIRsensorState;
      appDataReq.dstAddr = 1-APP_ADDR;
      appDataReq.dstEndpoint = APP_ENDPOINT;
      appDataReq.srcEndpoint = APP_ENDPOINT;
      appDataReq.options = NWK_OPT_ENABLE_SECURITY;
      appDataReq.data = appDataReqBuffer;
      appDataReq.size = 1;
      appDataReq.confirm = appDataConf;
      NWK_DataReq(&appDataReq);
      appDataReqBusy = true;
    }
    static void appTimerHandler(SYS_Timer_t *timer)
    {
      appSendData();
      (void)timer;
    }
    static void appInit(void)
    {
      NWK_SetAddr(APP_ADDR);
      NWK_SetPanId(APP_PANID);
      PHY_SetChannel(APP_CHANNEL);
    #ifdef PHY_AT86RF212
      PHY_SetBand(APP_BAND);
      PHY_SetModulation(APP_MODULATION);
    #endif
      PHY_SetRxState(true);
    
     
    
      HAL_BoardInit();
    
      appTimer.interval = APP_FLUSH_TIMER_INTERVAL;
      appTimer.mode = SYS_TIMER_INTERVAL_MODE;
      appTimer.handler = appTimerHandler;
    }
    
    /*************************************************************************//**
    *****************************************************************************/
    static void APP_TaskHandler(void)
    {
      switch (appState)
      {
        case APP_STATE_INITIAL:
        {
          appInit();
          appSendData();
          appState = APP_STATE_IDLE;
        } break;
    
        case APP_STATE_IDLE:
          break;
    
    
        default:
          break;
      }
    }
    
    /*************************************************************************//**
    *****************************************************************************/
    int main(void)
    {
      SYS_Init();
      PORTD=1<<PD0
      HAL_UartInit(9600);
      while (1)
      {
        SYS_TaskHandler();
        HAL_UartTaskHandler();
        APP_TaskHandler();
       lastPIRsensorState=PIRsensorState;
       Hibernate();
      }
    }
    The device communication works well when the Hibernate() function is not called.But when this function is called it enters into a deep sleep and communicate seldom .dis sleep mode affect rf communication?What is the mistake in my code please help.
     
    Uma Maheswary, Dec 14, 2016
    #1
    1. Advertisements

  2. Uma Maheswary

    pgib8

    Joined:
    Jul 26, 2015
    Messages:
    96
    Likes Received:
    21
    i'm not going to dissect your code, but is it possible that when your mcu is in sleep, it's not grabbing data from the rf chip, so that the rf chip fills up? is the rf supposed to keep working while the mcu is in sleep?
     
    pgib8, Dec 22, 2016
    #2
    1. Advertisements

  3. Uma Maheswary

    Uma Maheswary

    Joined:
    Dec 14, 2016
    Messages:
    2
    Likes Received:
    0
    yes.I need the rf should keep working while the mcu is in sleep
     
    Uma Maheswary, Dec 23, 2016
    #3
  4. Uma Maheswary

    pgib8

    Joined:
    Jul 26, 2015
    Messages:
    96
    Likes Received:
    21
    if the RF chip signals your MCU every time it received a packet, then your MCU reads out this data and so forth. If the MCU is sleeping, maybe it's possible this doesn't occur and the queue fills up. when the MCU wakes up again, the RF chip is full and won't send the signal that it received new packets. just a thought.
     
    pgib8, Jan 4, 2017
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brett Sharman

    RF communication

    Brett Sharman, Oct 23, 2003, in forum: Electronic Basics
    Replies:
    1
    Views:
    491
    Anders
    Oct 23, 2003
  2. Michael Noone

    Solutions for long range (3-5KM) RF communication?

    Michael Noone, Apr 24, 2005, in forum: Electronic Design
    Replies:
    23
    Views:
    1,248
    Frithiof Andreas Jensen
    Apr 26, 2005
  3. Winfield Hill

    new small relay breaks 300A at 400V

    Winfield Hill, Jan 27, 2006, in forum: Electronic Design
    Replies:
    16
    Views:
    993
    Walter Harley
    Jan 28, 2006
  4. gratefulmama333@gmail.com

    constant on/off breaks equipment

    gratefulmama333@gmail.com, Feb 25, 2006, in forum: Electronic Equipment
    Replies:
    6
    Views:
    520
    Chris Jones
    Feb 28, 2006
  5. Merv

    music breaks up on cd player

    Merv, Oct 4, 2004, in forum: Electronic Repair
    Replies:
    2
    Views:
    459
  6. Will777

    Two-way RF communication

    Will777, Sep 2, 2010, in forum: Electronic Projects
    Replies:
    13
    Views:
    1,376
    rob_croxford
    Sep 2, 2010
  7. Simmon

    RF power meter, tuning RF power amps, VNA

    Simmon, Mar 8, 2014, in forum: General Electronics Chat
    Replies:
    9
    Views:
    449
    brevor
    Mar 9, 2014
  8. Cona
    Replies:
    10
    Views:
    579
    (*steve*)
    Oct 3, 2014
Loading...