Giter Site home page Giter Site logo

micros-test's Introduction

micros-test

Testing a faster implementation of Arduino's micros() function

Arduino's implementation always returns multiples of four so I'm using the 16 bit timer from an Atmega328p. The timer runs at F_CPU(16 Mhz) in CTC mode without any prescaling. While polling continuously, the smallest time interval that can be measured without significant error seems to be 5µs and there's an error of 0.05µs to 0.2µs in the readings. The overhead for the function call seems to be 3-4µs in this example so I'm checking for 7µs instead of 10µs. The error and overhead could change in different examples since there's varying overhead involved in checking the loop condition for different values and toggling pin 5 on PORTD.

timer1_overflow_count is incremented once every 256µs and 16 counts of TCNT1 take 1µs. It wraps around after 71.58 minutes.

usage

  • cd to the directory
  • run make all
  • run avrdude -p m328p -c 'your-programmer-type' -P 'your-COM-port' -U flash:w:microsTest.hex:i

screenshots

alt tag

  • Testing at 10µs

alt tag

  • Testing at 15µs

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.