Code Monkey home page Code Monkey logo

pic16f15244-wdt-wake-up's Introduction

MCHP

Wake-up from Sleep using the Watchdog Timer with PIC16F15244

The 'pic16f15244-wdt-wake-up' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to use the Watchdog Timer (WDT) to wake up the microcontroller when it is in Sleep mode.

PIC16F15244 Curiosity Nano Development Board:

Curiosity Nano Development Board

Related Documentation

Software Used

Hardware Used

  • PIC16F15244 Curiosity Nano (EV09Z19A)
  • Micro-USB to USB 2.0 cable

Setup

  1. Connect the PIC16F15244 Curiosity Nano board to a PC using the Micro-USB to USB 2.0 cable.
  2. If the system not ready, download and install MPLABX IDE version 6.10 (or newer).
  3. If the system not ready, download and install the XC8 C-Compiler version 2.41 (or newer).
  4. Open the 'pic16f15244-wdt-wake-up.X' project as shown in Figure 1.
Figure 1: Open Project Window

Open Project Window

  1. Click-> Project Properties button to open the Project Properties window. Select the Curiosity tool from the Tools drop-down menu as shown in Figure 2.
Figure 2: Select the Nano in Project Properties Window

Select Tool

  1. Click-> Make and Program Device button to program the PIC (see Figure 3). Verify that the device was successfully programmed (see Figure 4).
Figure 3: 'Make and Program Device' Button

Program Device Button

Figure 4: Program Complete

Program Complete

Operation

After the Nano board is programmed, the Watchdog Timer is enabled, and LED0 will be in its 'ON' state. After a one second delay, the SLEEP() command is issued, which puts the microcontroller into its Sleep state. If the WDT reaches its maximum time period before a Clear WDT (CLRWDT()) command is issued, the WDT will wake up the device.

The WDT can be used to reset a program, if the program stops executing code for a certain amount of time, or as a way to wake up the device after a period of time. In this example, the WDT is configured to time-out after approximately four seconds (see Figure 5). When the time-out occurs, the microcontroller wakes up, and begins to toggle LED0 every 500 ms. Example 1 shows the main() loop, which executes the SLEEP() command, and begins to toggle LED0 after the WDT wakes up the device.

Figure 5: WDT Configuration in MCC

WDT Configuration

Example 1: Main() Code Snippet
int main(void)
{
  SYSTEM_Initialize();

  CLRWDT();           // Clear WDT

  LED0_SetLow();      // Turn ON LED
  __delay_ms(1000);   //Delay 1 Second
  SLEEP();            //Issue Sleep Command

  while(1)
  {
      LED0_Toggle();    //Toggle LED
      __delay_ms(500);  // Delay 500 Milli Second
      CLRWDT();         // Clear WDT
  }
  }

Summary

The 'pic16f15244-wdt-wake-up' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to use the Watchdog Timer (WDT) to wake up the microcontroller when it is in Sleep mode.

pic16f15244-wdt-wake-up's People

Contributors

aku-work avatar ashishmakthal avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.