Two AVR-GCC examples of using AVR 8 bit Timers

Timers are an essential part of microcontrollers. They can be used in many areas starting with simple timed routines to RTOS. The good thing is that timers run independently of the main program flow. Set up the timer counter and let it do its job while your main program runs and does its job. Let’s take the AVR Atmega8 microcontroller. It has two independent 8-bit timers. One is a little simpler which is featured with essential functions like: Single-channel counter; Frequency generator; External Event counter; 10 – bit clock pre-scaler. Another is more advanced where is OCR (output compare register) included, which allows implementing PWM routines. It has the following features: Single Channel Counter Clear Timer on Compare Match (Auto Reload) Glitch-free, phase Correct Pulse Width Modulator (PWM) Frequency Generator 10-bit Clock Pre-scaler Overflow and Compare Match Interrupt Sources (TOV2 and OCF2) Allows Clocking from External 32 kHz Watch Crystal Independent of the I/O Clock Datasheet documents these timers pretty well. Let’s view a couple of examples with both 8-bit timers. The first example is to do a simple task – every time timer overflows, it has to increase the variable value. And this variable is sent to PORTB in…

Continue reading

Simple TTL to RS232 adapter

During my spare time, I made a quick TTL design for an RS232 adapter that works with my AVR development board. This adapter helps to connect TTL (Transistor-Transistor Logic) level signals to the RS232 interface. TTL side is a 9-pin female connector, and RS232 sire is a male connector. The unit is powered from the target board using power pins. The RS232 TTL adapter circuit: Put all the in a plastic case and see what I have got:

Continue reading

Simplest dor-bell based on AVR microcontroller

This circuit is so simple, and generated sound may look ugly, but on the other hand, this is a good starting point for newbies with AVR projects. This circuit is made of one IC AT90S2313 (may be substituted by Attiny2313). The circuit is low power and reliable as it consists of very few parts (if SMD chip used, then it can be placed inside a postcard): A microcontroller can be powered by using from 2.7 to 6 V power supply. If the AT90S2313 microcontroller is used, then you need to connect a crystal resonator. If ATtiny2313 is used, you can use an internal RC clock source and reduce the number of parts needed. Transistors can be any general-purpose transistors. If the sounder requires less than 20mA of current, you may connect it directly to the port pin. After reset, the circuit starts the program and plays a melody one time. After that, it goes to power-down mode. Crystal frequencies may be chosen from 32768 to 10MHz. Firmware is written for 10MHz. If you use a different clock source, then reduce SoundTab coefficients in the source code and rebuild it. Download Source code

Continue reading

Logical elements and their classification

Logical elements are circuits that perform logical operations. Logical elements are used in digital circuits and are used to express Boolean algebra. The system of logical operations was defined by George Boolean English mathematician in 1848. Firs logical element was used by Ernest Nagel in 1910. It was a calculator made of telephone relays… Let’s go to nowadays and clarify what is logical algebra. There are only two values in logical algebra: True or False , they are identified as numbers 1 for True and 0 – for False. Because there are two digits used, so this is why digital electronics is called as it is – Digital Electronics – the electronics which operates with two digits. Logical operations may be as follows: Logical negation – ¬A (in different sources negation has various markings like Ä); Logical OR – C=A + B (in other literature you may find C=AuB); Logical AND – C=A*B (in other literature you may find C=AˆB). There is whole theory of logical algebra. You may find a lot information in Wikipedia sources.

Continue reading

ATMEL AVR ISP programmer that works with AVRStudio4

Probably many AVR software developers that use the AVRStudio4 environment would like to program chips directly from AVRStudio4 using AVRISP. Usually, we use a simplified version of AVRISP that works with PonyProg or AVRDUDE. But here is the solution that can solve this problem. In sixca.com is a populated simplified version of the AVR ISP programmer that works with ATMEL original programming software. IC1 stands for any RS-232 driver like MAX232 or any similar(DS275). The wire from AVR-ISP to AVR board should not exceed 15cm.

Continue reading

All you need to start with Atmel AT89 microcontrollers

This is a simple development board for the Atmel AT89 series of microcontrollers that uses ISP programmability I found in sixca.com. This is a good start for learning with MCS-51 based projects. This board supports Atmel microcontroller series like AT89S51, AT89S52, AT89S53, AT89S8252 with DIP40 pin packages. The board uses the ISP programming method through the parallel port adapter. It has all I/O connectors, single-sided PCB. It has an onboard voltage regulator 7805.

Continue reading

Signal power and energy calculation

The most common signal characteristics are energy and power. In signal theory, these terms require additional comments because they are different from what we are using in AC or DC systems. What are power and energy? When we connect the R resistor to voltage U, the resistor will dissipate some power equal to P=U2/R. During time T, the energy loss on this resistor will be E= TU2/R. Now let us say that we add some signal s() instead of DC voltage. In this case, the power will depend on time as the signal is time-dependent. The term is called instantaneous power: p(s)=s(t)2/R

Continue reading

AVR serial and parallel High-Voltage programmer

This programmer isn’t widely popular as usually is easier to use the ISP programming method. But sometimes if you need to disable the RESET pin and use it as a regular pin instead or you want to disable or restore SPI fuses that control the ISP programming method, then you will need a High-Voltage parallel programmer of AVR microcontrollers. One of the programmers available on the wide internet is HVProg. This is a redesign of STK500 but without development board components. This programmer supports all available AVR microcontrollers in every programming mode and is compatible with AVRstudio. In HVProg there are two versions of programmer:

Continue reading

avrdude-gui another easy way to program AVR microcontrollers

Avrdude-GUI is a simple graphical user interface(GUI) for avrdude, a command-line tool running on several OS to program the Atmel AVR Microcontrollers. AVRDUDE-GUI is included in the WinAVR toolset and can be used separately to program AVR chips avoiding the command line as it has to be done with plain AVRDUDE. This program has no installation or uninstallation routines. It just has to be in the directory where the avrdude is located. It has almost all functions needed to program AVR microcontrollers effectively. A few things that need to be done are reading fuses and working with single fuse bits. Now you have to define whole fuse bytes what is not very convenient.

Continue reading

Old good AVR delay loop generator program

This is not a new program, but I decided to add it here because I found it very handy in many cases while developing ASM programs. This small program generates delay loops for ATMEL AVR controllers. It’s multilingual – for now, it supports English and German languages. You can change the program’s GUI language by clicking on one of the flags. The program can generate really long delays. I have tried to enter like the 60s for 16MHz – the code generated without problem To generate a delay loop in ASM source code just follow the steps in the left part of the window Enter the number of cycles of the delay loop. You cannot enter the delay time in seconds as the author promised to implement this feature in the future. Click the GO-Button Copy the source to your ClipBoard (Copy/Paste). Watch out for register collisions in your ASM source! If they are used, save values in the stack before or select different ones. An update! It appears that only a third party web version of the tool is available. A link to a web-based delay loop generator

Continue reading