
More efficient, and unless your algorithm requires a lot of math, a fast processor Having a slower clock makes your microcontroller BAD JU-JU!!!Ĭlick the Fuses tab (see below image), and uncheck 'Divide clock by 8'. You could permanently disable your microcontroller from being further programmed. If you push the wrong fuse, there is a possibility Now power up your microcontroller and connect it to your AVR as if you were to program it: Open up global.h and set the CPU to 8Mhz:

I recommend not using the timer because its default interrupt settings willĬause your servos and UART to spass out. Just add these lines at the top of your code where you declare includes. Now your compiler knows to use these AVRlib files. AVRlib includes #include "global.h" // global settings #include "buffer.h" // buffer function library #include "uart.h" // uart function library #include "rprintf.h" // printf library //#include "timerx8.h" // timer library (timing, PWM, etc) #include "a2d.h" // A/D converter function library Open up SoR_Utils.h and add in two AVRlib files, uart.h and rprintf.h: Then you already have AVRlib installed and ready to use (so don't worry about it).Īlso, look for this line towards the top:Īnd replace it with your desired frequency. If you are using the $50 Robot source code,

SRC = $(TARGET).c a2d.c buffer.c rprintf.c uart.c (C dependencies are automatically generated.) Open up your makefile, and add in rprintf.c and uart.c if it isn't already there: I will also show you how to change it to your frequency of choice. (all individual components and code) to 8MHz. Since we do not have an external crystal, we will configure the entire system Listed in the 'System Clock and Clock Options->Calibrated Internal RC Oscillator' section. "By default, the Internal RC Oscillator provides an approximate 8.0 MHz clock."

How do you know what that frequency is?įrom the datasheet of your ATmega8/ATmega168, we can find: We will be using the maximum frequency that your microcontroller can handle withoutĪdding an external crystal. To use right away and skip this tutorial, or I can explain how and whyĬan 'catch your own fish' without me giving it to you in the future. Now of course I could just give you the code for you (or any AVR based microcontroller) you need to make a few minor modifications to your codeĪnd add a small amount of extra hardware. How to Build a Robot Tutorials - Society of RobotsĪdding UART Functions to AVR and your $50 Robot
