Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Watchdog with NRF24LE1 (Part 9/14)

By Amanpreet Singh November 14, 2021

Making Watchdog Timer with NRF24LE1 Circuit

Till now in the series on NRF24LE1, we have covered many interesting and special features which differentiate NRF from others. Today we are going to discuss an important functionality of microcontrollers which helps them recover from failure. Suppose, I give you a task to solve in predefined time and you fail to do it in allotted time then you will have to start it from the beginning. The word ‘Timeout’ can be used here to clarify the concept.

Prototype of NRF24LE1 based Watchdog Timer

Fig. 1: Prototype of NRF24LE1 based Watchdog Timer

But do you know that microcontroller can also keep track of time and if it fails to achieve the task in allotted time, it can restart itself. This is done in order to avoid malfunction and hanging. Or we can say in case of system failure it automatically restarts itself. This also eliminates the need of human for manual restarting. It is an essential part in designing remote and automated systems. The timer which is used to keep track of time is known as Watchdog Timer. The name is itself clear. The Mars Rover also uses this functionality to recover from system failures and malfunction.

Some features of Watchdog Timer in NRF24LE1 are:

• Minimum Watchdog timeout interval : 7.8125ms

• Maximum Watchdog timeout interval : 512 s

• Uses 32.768 KHz frequency clock

• 16- bit register timer
For controlling Watchdog we have WDSV register. It holds 16-bit counter value and is divided into two bytes- MSByte and LSByte. To write the counter value to this register we first have to write LSByte and then MSByte. Same will be for reading the register. The two bytes must be read or write continuously. We can’t read any byte while writing and vice versa.  The readout of WDSV register will always give the start value of the counter or the initial value. We can’t get current value of the watchdog timer by reading WDSLV.
Watch Dog Timer with NRF
The watchdog timer gets activated when two bytes have been written. It counts down from WDSLV*256 to 0. When counter value gets 0,the microcontroller restarts itself. This restart is same as hardware restarting. To avoid reset we can WDSV register with new or same value.
The counter gets restarted if WDSV is written. It is done when our system is working properly and we don’t want reset.
The watchdog timeout in seconds is given by:
         WDSV*256/32768
Watch Dog Timer with NRF24LE1
The watchdog gets disabled when the system is restarted or when we are using NRF in register retention or memory retention power saving modes. It uses 32.768 KHz low frequency clock. Before using timer we have to enable the clock. This frequency can be provided externally or can be derived from 16 MHz crystal oscillator. The source of 32.768 KHZ can be controlled by CLKLFCTRL (Clock Low Frequency Control) register. The contents of this register are – :
• Bit 7 – Read CLKLF(phase)
• Bit 6 – CLKLF ready to be used
• Bit 5:4 – Reserved
• Bit 3 – Read 16 MHz clock source. 1: Crystal Oscillator, 0: RC Oscillator
• Bit 2:0 – Source for CLKLF.
000: Crystal 32K
001: RC 32K
001: Synthesized from 16 MHz Crystal
011: From IO pin used as XC1 to XOSC32K (low amplitude signal)
100: From IO pin (digital rail-to-rail signal)
101: Reserved
110: Reserved
111: None selected
Simple steps to use the Watchdog functionality are:
• First we have to enable 32.768 KHz clock. For that we use CLKLFCTRL register. For simplicity we will use synthesized clock. We can do it by writing 001 in Bit2:1.
• Then we have to check if the clock has started or not. We can do this by checking Bit 6.
• After that we can write LSByte and then MSByte of WDSV.
We can also use functions provided by Nordic Library:
FUNCTIONS INPUT PARAMETER OUTPUT DESCRIPTION
hal_wdog_init() 16-bit start value – To initialize the watchdog timer with start value
hal_wdog_restart() – – To restart the watchdog timer to avoid reset

We have written a code to understand the functioning of Watchdog properly.

 

You may also like:


  • What are the top development boards for AI and ML?

  • What types of motors are used in electric vehicles?

  • What is Wireless Electric Vehicle Charging System (WEVCS)?
  • battery selection low power design
    What are the battery-selection criteria for low-power design?

  • What are the different types of integrated circuits?

  • What is Microcontroller?

Project Source Code

###

//Program to 
#include"reg24le1.h" // I/O header file for NRF24LE1
#include"hal_delay.h" // header file containing delay functions
#include "hal_wdog.h" // watchdog functions library
 
// main function
void main()
{
 
CLKLFCTRL = 0x02;   // starting 32.768 clock
 
while(!( CLKLFCTRL & 0x40));  //waiting for clock to start
 
P0DIR = 0;  // port0 as output
 
P0 = 0xff;  // port0 high
delay_ms(200);  // wait 200ms
P0 = 0x00; // port0 low
 
hal_wdog_init(0x0200); // 4seconds time-out
 
while(1);  // infinite loop
 
 
}

###

 


Circuit Diagrams

Circuit-Diagram-NRF24LE1-Based-Watchdog-Timer

Project Video


Filed Under: Tutorials

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Will this TL084C based current clamp circuit work?
  • ADS optimization cockpit window does not open
  • Voltage mode pushpull is a nonsense SMPS?
  • How to determine the maximum PAD frequency ?
  • Xiaomi Mijia 1C Robot problem of going backwards while working

RSS Electro-Tech-Online.com Discussions

  • Curved lines in PCB design
  • using a RTC in SF basic
  • PIC KIT 3 not able to program dsPIC
  • Siemens large industrial PLC parts
  • Parts required for a personal project

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection
  • Convection-cooled power controller integrates EtherCat connectivity

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe