The low frequency oscillator is used to control the sleep/wakeup timer. The sleep/wakeup timer controls the measurement frequency i.e. how often the AD5940 wakes up to run a measurement sequence. Refer to the Sleep/Wakeup Timer chapter in the AD5940 datasheet for further details. For applications requiring a highly accurate measurement sample rate, the sleep/wakeup timer needs to be calibrated. The calibration function uses two measurement sequences. The first sequence starts the timeout counter and second sequence stops the timeout counter and generates an interrupt to the MCU to read back the timeout value. The second sequence is then modified to reset the timer so the length of time required for the MCU to read back the timeout value can be measured. It is important that SPI speed is fast, ideally 16MHz. Slower SPI speeds will reduce calibration accuracy. Also using an external 16MHz crystal will increase calibration accuracy.
The following are the steps required to calibrate the LFOSC:
Frequency = (SystemClkFreq ×WuptPeriod) / (TimerCount2-TimerCount)
where, Frequency = Low Frequency Oscillator Frequency SystemClkFreq = Frequency of AD5940 system clock (Ideally 16MHz using external crystal) WuptPeriod = Period of the wakeup timer
The code to carry out the low frequency oscillator calibration is included in the AD5940 SDK. The function AD5940_LFOSCMeasure() is used. The function takes two input parameters. THe fist parameter is a pointer to the data structure LFOSCMeasure_Type that contains the measurement parameters. The second argument is a pointer to a variable that stores the result of the calibration. This structure contains the following paramteres:
The result of the calibration is then used in the calculation for the period of the sleep/wakeup timer. The sleep/wakeup timer configures the sampling frequency of measurements so after this calibration a high level of accuracy is achieved. For highest accuracy it is best to use a precision 16MHz crystal connected to the AD5940.