Table of Contents

Arduino notes

On this page, I'm collecting some personal notes on programming the arduino microcontroller board. The arduino is great, but sometimes you want to do things that go beyond what the basic API provides, for example setting up timers, or increasing the ADC sample rate. This involves delving into the AT-Mega 328p datasheet, which you can download here. The notes below are meant to be read in conjunction with the datasheet, not as a complete guide.

This is just an index page - the pages with the full notes are listed below.

  • Pin assignments. Which internal ports are connected to which IO pins.
  • Programming timer 2. How to set up the 8 bit timer 2 for counting, timing, PWM, clock interrupts etc.
  • Increasing the ADC sample rate up to 76 kHz (the standard value is 10 kHz). This allows you to read higher frequency signals.

Some other things that I know are possible but haven't got round to writing up.

  • You can set non-standard clock speeds for the USB serial connection just using the standard API. I've had it working up to 230.4 kBaud, and higher speeds are supposed to be possible.
  • You can read the ADC asynchronously by using the chip's registers. The standard analogRead() function waits for the conversion to complete before returning, but this wastes cycles which your program could spend on something else.

If you want to use the built in timer / counter units, it's best to use either timer 1 (16 bit), or timer 2 (8 bit). Timer 0 is used by the arduino API for internal timing, so it's best avoided unless you have a good reason and know what you're doing.

 
arduino/start.txt · Last modified: 2011/07/21 08:43 by andy
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki