Giter VIP home page Giter VIP logo

microchip-pic-avr-examples / pic18f47q10-cnano-tmr0-16bit-sleep-int-mcc Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 7.1 MB

This repository provides a MCC-generated code example for using TMR0 in 16-bit Mode with sleep operation. An interrupt will wake up the device every 10s and LED0 will light up for 100 ms and then the MCU will be put back to sleep.

Makefile 6.34% C 93.66%
int low-power melody sleep tmr

pic18f47q10-cnano-tmr0-16bit-sleep-int-mcc's Introduction

MCHP

Timer0 in 16-bit Mode with Periodic Interrupt using the PIC18F47Q10 Microcontroller with MCC Melody

This repository contains an example of MCC Melody-generated source code for Timer0 (TMR0) as described in TB3285 - Getting Started with Timers/Counters on PIC18 document from Microchip. This example shows how to configure the TMR0 in 16-bit mode, and generate an overflow interrupt every 10 seconds, using LFINOSC as a clock source. TMR0 runs while the microcontroller (MCU) is in Sleep mode.


A GPIO pin (the development board’s on-board LED) will be configured as output and when the interrupt occurs, the microcontroller is woken up, the LED is lit for 100 ms and then the microcontroller is put back in Sleep mode.


The code was generated using MPLAB® Code Configurator.

Related Documentation

Software Used

Hardware Used

  • PIC18F47Q10 Curiosity Nano Development Board is used as a test platform. (DM182029)
  • Oscilloscope / Logic Analyzer

Operation

To program the Curiosity Nano board with this MPLAB® X project, follow the steps provided in the How to Program the Curiosity Nano Board chapter.

1. Setup

The following peripheral and clock configurations are set up using MCC Melody for the PIC18F47Q10:

  • Clock Control:

    • Clock Source: HFINTOSC
    • HF Internal Clock: 1 MHz
    • Clock Divider: 1
  • TMR0:

    • Enable Timer: Enable
    • Clock Prescaler: 1:32
    • Postscaler: 1:1
    • Timer Mode: 16-bit
    • Clock Source: LFINTOSC
    • Enable Synchronization: Disabled
    • Requested Period (s): 10 seconds
    • TMR Interrupt: Enabled

Configuration Bits:

  • CONFIG3L:
    • WDT Operating Mode: WDT Disabled
  • CONFIG4H:
    • Low Voltage Programming Enable: Enabled

The following pin configuration must be made for this project:

Pin Configuration Function
RE0 Digital Output LED0

2. Demo

This demo shows how the TMR0 interrupt works when the MCU is in Sleep mode. The on-board LED toggles every 10 seconds when the timer interrupt wakes up the MCU.


The LED signal is shown in the logic analyzer software picture below.


3. Summary

This project provides an example of a basic use case based on TMR0 interrupt.

How to Program the Curiosity Nano board

This chapter shows how to use the MPLAB® X IDE to program an PIC® device with an Example_Project.X. This can be applied for any other projects.

  • Connect the board to the PC.

  • Open the Example_Project.X project in MPLAB X IDE.

  • Set the Example_Project.X project as main project.

    • Right click on the project in the Projects tab and click Set as Main Project.
  • Clean and build the Example_Project.X project.

    • Right click on the Example_Project.X project and select Clean and Build.
  • Select the PICxxxxx Curiosity Nano in the Connected Hardware Tool section of the project settings:

    • Right click on the project and click Properties
    • Click on the arrow under the Connected Hardware Tool
    • Select the PICxxxxx Curiosity Nano (click on the SN), click Apply and then click OK:
  • Program the project to the board.

    • Right click on the project and click Make and Program Device.

pic18f47q10-cnano-tmr0-16bit-sleep-int-mcc's People

Contributors

aku-work avatar mariusnicolae 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.