Code Monkey home page Code Monkey logo

millis's Introduction

Millis

This library allows you to use millis function like with Arduino. Millis function returns time in ms from the program start.

Implementation

  1. Add "millis.h", "millis_config.h" and "millis.c" files to your project
  2. Select Timer/Couter which you want to be used by millis library and assign the right number to the MILLIS_TC_NUM macro located in the "millis_config.h" file.
    • Timer/Counter0 -> 0, Timer/Counter1 -> 1

Hardware support:

ATtiny84A, ATtiny85, ATtiny88

  • It is possible to add another AVR MCUs, just add another conditional directives (#if defined(\_\_AVR\_*YOUR_DEVICE*\_\_)), assign the right registers and set the right OCREG_VALUE in millis_config.h file.

  • CPU clock is 8 MHz, but it is possible to implement different CPU clock, just set the right OCREG_VALUE and prescaler in millis_config.h file.

  • When running at 8 MHz, following settings are highly recommended:

    • 8-bit Timer/Counter: OCREG_VALUE = 124, prescaler = 64
    • 16-bit Timer/Counter: OCREG_VALUE = 7999, prescaler = 1

How to use

  • Execute millis_init() function to set registers and interrupts.

  • Then just call millis() function to get time in ms.

  • You can call resetMillis() to reset 32-bit millis counter to prevent variable overflow.

  • Make sure to execute sei() function to enable global interrupts.

millis's People

Contributors

tekl7 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

nuxeh

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.