Post Go back to editing

AD5940: Wakeup and Sleep Timer Setup

Category: Software
Product Number: AD5940
Software Version: v0.2.1

I am trying to understand the purpose of some hardcoded numbers in the example code. I see similar lines of code in Amperometric.c, ChronoAmperometric.c, Electrocardiograph.c, Impedance.c, etc...   Specifically, I am curious about these two lines of code:

      1. wupt_cfg.SeqxSleepTime[SEQID_0] = 4-1;
      2. wupt_cfg.SeqxWakeupTime[SEQID_0] = (uint32_t)(AppAMPCfg.WuptClkFreq*AppAMPCfg.AmpODR)-4-1;
The recommended operation on Page 107 (Rev D datasheet) is to disable to sleep timer and use the sequencer to put the device in sleep mode at the of the sequence.  If we are not using the Sleep timer, the:
Q1:  Is Line#1 even necessary?  
Q2:  If not, do we need the "-4-1" in Line#2?
Q3:  Is the "-1" due to the hardware operation?  In other words, does the timer trigger an action at the end of the 0 count?
I also see a "-2" in places instead of the "-1" (see SqrWaveVoltammetery.c) and code comments in other files that say "The minimum is 1.  Do not set it to zero...."
Q4:  Why a "-2" in places?  Is there a minimum?  Please explain the origin of these numbers, any minimum setting that should be used.
Thank you

Added the product number to the subjetc field
[edited by: JEstayo at 2:08 AM (GMT -5) on 22 Feb 2024]
  • Hi  ,

    I will contact the product owner and get back to you.


  • 01. Yes, you need line#1. The sleep timer isn't disabled, rather it's the function that puts the device to sleep when the sleep timer elapses that is disabled. After much searching I believe the disable is hard coded in this register/data pair {0x0a00, 0x8009} in the AD5940_Initialize routine. Set this way, the device will go to sleep at the end of the sequence execution.

    03. I think you're right about the -1 and zero count, A value of 3 will give 4 clock cycles, 3,2,1,0

    Note that there's an error in the second line of code. The clock frequency should be divided by the data rate. For example, if you want to measure 2 times per second the value loaded into the timer needs to be half as large. 

    wupt_cfg.SeqxWakeupTime[SEQID_0= (uint32_t)(AppAMPCfg.WuptClkFreq/AppAMPCfg.AmpODR)-4-1;

    And not to hijack the thread, but I landed here after spending the better part of the day yesterday trying to prevent the device from going to sleep so that the waveform generator stays on continuously. I'd appreciate it if the AD rep could comment on this, too. 

  • Hi,


    The lines 1 and 2 are point 5 of the recommended operation on Page 107 (Rev D datasheet).

    If there is a requirement to

    - run the measurement using sequences,

    - trigger measurement sequences by wakeup timer and

    - save power by putting the device to sleep when not measuring, 

    then these lines above are necessary.


    Minimum value allowed for wupt_cfg.SeqxSleepTime[SEQID_0] is "1".

    Since output data rate is set by AmpODR,

    these values are set such that 

    wupt_cfg.SeqxWakeupTime[SEQID_0] + wupt_cfg.SeqxSleepTime[SEQID_0] = (AppIMPCfg.WuptClkFreq/AppIMPCfg.ImpODR)

    Hence, if SeqxSleepTime is set to 4,

    then SeqxWakeupTime is set to  "(AppIMPCfg.WuptClkFreq/AppIMPCfg.ImpODR) - 4 "

    "4-1" etc found in code are values set for specific applications after trial runs.

  • Thank you for answering jjd's question. As a follow-up, is it possible to keep the sequencer from returning to sleep? I'm doing BIA measurements with the AD5940 BIA example code and would like the waveform generator to remain on continuously.  I tried setting SEQSLPEN and TMRSLPEN to 0 in the AD5940_Initialize routine but that didn't seem to work.