Saturday, October 1, 2011

Tutorial 4 : Connecting External Crystal Oscillator to Atmega (Atmel AVR) series. [Lower FUSE BITs settings for Atmel AVR]

Name : Connecting the crystal oscillator to Atmega (Atmel AVR) series.

Application :
  • This tutorial will illustrate how to connect external crystal oscillator to Atmega16/32, physically and logically.
  • It also explains the concept of fuse bits and how to configure Lower Fuse Bits setting.
Requirements and components :
  • All components required to make the development board (click here)
  • Parallel port programmer (click here)
  • Software : PonyProg2000 (click here)
  • Atmega16 data-sheet.
    (Data-sheet of Mega AVR : Need to refer for Fuse Bits)
Connecting crystal with Atmel AVR is two phase process.
In phase one, we connect the crystal oscillator physically
In phase two, we connect it logically to micro-controller.
(This is done by changing Lower Fuse Bits)

Connecting crystal to megaAVR (Physical connection) :
Following diagram shows how to connect the crystal oscillator to Atmega (Atmel AVR) series.
Note : All connections are shown in this tutorial (click here)

Kindly refer data-sheet of AVR your using, page number 2 will give you all idea about pin configuration.
All MegaAVR data-sheets (click here)

Selecting the values of C1 & C2 :  
Values of capacitors C1 and C2 will change, based on the crystal value
Following table shows the recommended for capacitors C1and C2.


(Available under System Clock and Clock Options header in all MegaAVR data-sheets)
e.g 1.> Crystal oscillator frequency = 11.0592 MHz=>22pF
e.g 2.> Crystal oscillator frequency = 16.0000 MHz=>22pF


Fuse bits :

Fuse bits define the mode of operation for MegaAVR.
Changing the fuse bits changes the internal configuration of micro-controller .
To able to connect the crystal logically, we must change the lower fuse bits.

Note :
Changing fuse bits is like doing open hart surgery on micro-controller.
Any wrong configuration of fuse bits will result in the dead MegaAVR.

Lower Fuse byte :
Lower fuse byte deals with Brown-out Detector, start-up time & Clock source.
In short lower fuse byte is for clock source configuration.
Here is the bit configuration of Lower fuse byte.

Following table shows the description of above bits.
  
Now default Lower fuse is 


Reading Fuse bits with PonyProg : 
  • Start PonyProg2000
  • Connect the parallel port programmer to parallel port at PC and development board.(Turn on the power of development board)
  • Complete the interface setup, calibration and device selection.
    (For tutorial click here)
  • In menu bar click on Command and then click on Security and configuration bits(Command > security and configuration bits)


  • This reads fuse bits from micro-controller, and displays it in new window.
  • Now above window shows the default fuse bit status.
    Fuse bits marked in red are Lower fuse bits.
  • For PonyProg Check = 0 and Un-check = 1
  • To read the fuse bits again click on read button
Calculating the Lower Fuse bits for 16MHz :
Following table shows the CKSEL3..0 (read as CKSEL 3 down to 0) for device clocking options .

Following table shows the value specific settings for fuse bits 


Note :  CKSEL0 bit is configured for start up time we'll keep it as it is 
(Do not change the CKSEL0 bit)

Hence as above two table shows bit configuration for 16MHz will be
  • CKSEL3 => 1 => Un-check in Ponyprog
  • CKSEL2 => 1 => Un-check in Ponyprog
  • CKSEL1 => 1 => Un-check in Ponyprog
  • CKSEL0 => 1 => Un-check in Ponyprog (By default it is Un-check)  
  • CKOPT  => 0 => Checked in Ponyprog
There for new Lower fuse bit configuration for 16MHz crystal is

Writing Fuse bits with PonyProg :
  • To un-check a bit click on the check box in front of particular bit.
  • To implement change in Ponyprog un-check the CKSEL3..1 (read as CKSEL 3 down to 1) and check the CKOPT as shown in fig below.

  • To write fuse bits click on Write button.
  • This will perform write operation.
This is how to configure and change the fuse bits using PonyProg.

Note :
It my previous experience that any wrong configuration of fuse bits may result in to dead MegaAVR.

Before writing the fuse bits verify the configuration at least twice.

Disclaimer :
All the data or information written above is from data-sheets and other reference documents.
My intention is to share my knowledge and experience with others.
Information or data above is not my innovation at all, its just a collection that works perfectly.

Friday, September 16, 2011

Tutorial 3 : Getting started with PonyProg.

Name : Getting started with PonyProg (parallel and serial port programmer)

Application
: How to configure the PonyProg to make it work with parallel port programmer.( illustrated in tutorial 1.)

Requirements and components :
  1. x86 based PC with suitable o/s  (I use windows XP SP 3)
  2. Software : PonyProg 2000 (Free to download Click here)
    (As I use windows XP SP 3, so I used to download suitable version)
  3. Refer this tutorial to generate .hex file which is to be burned in uC.
Installing the  PonyProg2000 :
  • Download the suitable version click here .
  • PonyProg2000 setup file.
  •  Double click on the setup.exe
    (This will open the installation wizard)
  • Click next .
    (This will open the licenses agreement window, accept the licenses and click next)
  • Select installation directory, by default it is C:\Program Files\PonyProg2000.
    (To change the installation directory click on Browse option)
    Click Next .
  • Click Next : This will create the start menu shortcut .
  • Click on the Install to install PonyProg2000
  • This will install the PonyProg2000 on your system.
    Un-check  the View README.TXT check box.
    Then Click on the Finish .

This will complete the installation on your system.

Configuring PonyProg2000 :
  • Now right click on My Computer .
    Then click on Manage
  
  • This  will start Computer Management wizard
    In the console tree (on left hand side) click on Device Manager
  

  • Now expand Port (COM & LPT ) menu.
    Note down the Printer Port.
    Here, I'm having LPT1. 
     
We need all this stuff for configuring the PonyProg2000
  • Turn on your speakers to enjoy special sound effect !!
    Click on start -> All Programs -> PonyProg -> PonyProg2000

    (This will start the PonyProg2000)

  • Now click on OK.
  • This will open a pop-up window asking you to run the calibration
  • Click on OK.
  • This will open one more pop-up saying "Initial setup is require".
  • Click on OK.
    (Now PonyProg2000 is ready for configuration.)
 Above fig shows the default view of PonyProg2000
________________________________________________________
STEP 1: Interface setup...
________________________________________________________
In menu bar click on the Setup and then click on the Interface Setup.. 
 
This will open up the I/O Port Setup window.
________________________________________________________
STEP 2 :
________________________________________________________
Click on Parallel (radio button) to select the Parallel programming mode.
From drop-down menu below Parallel (radio button)
select the Avr ISP I/O .
Then click on LPT1 (radio button).
(as shown below)
Now click on OK, to complete the I/O Port Setup
NOTE : Do not disturb the other settings .

________________________________________________________
STEP 3 : Calibration
________________________________________________________ 
In menu bar click on Setup and then click on Calibration .
This will open the window asking for your conformation.
Note : Remove all the connection from LPT1 (if there are any)
Click on Yes button.
This will calibrate the bus timing.

Another pop-up window will come up saying that, Calibration OK.
Click on OK.
Now we are done with initial setup !!!
It's time to select the Micro-controller.......



________________________________________________________
STEP 4 : Device selection
________________________________________________________
In menu bar click on device button, this will open a drop down menu.
Move the mouse pointer to AVR micro, this will open a drop down list of the AVR micro-controllers those can be programmed using PonyProg2000
Select the appropriate one by clicking on the option,
(Here I'm selecting ATmega16)

________________________________________________________
STEP 5 :
________________________________________________________
Once we change the device to ATmega16 one can notice the two changes
1.  In navigation tool bar you will find AVR micro and Atmega16 on left hand side.
2.  status bar will also display the same settings.(at bottom)

________________________________________________________
STEP 6 : Loading the .hex file in PonyProg2000
________________________________________________________
To find how to locate the .hex file after successful compilation (using CodeVisionAVR) refer this tutorial (click here)
(path will be ##/cvavr2>Bin>Exe)
Now we can locate the Hello_embedded.hex file.
To load file ->
1.  In menu bar click on the File and select Open Device File ... option

2.  This will open the "Open device content file" window.
3.  Change the "File of type" option to .hex (as shown below)
4.  Navigate to proper folder in order to find the .hex file using look in drop-down menu.
5.  Now select the  Hello_embedded.hex and then click open button
6. This will load the Hello_embedded.hex in PonyProg2000 (see fig bellow)


________________________________________________________
STEP 6 : Programming the micro-controller
________________________________________________________
(some people also refer it is as Burning uC or writing uC

1.  Connect the Parallel port programmer to Parallel port (PC) and programming pins of development board (micro-controller).
2.  In menu bar click on the command and then click on Write All option.

3.  PonyProg will ask for your permission .
4.  Click on the Yes button.
5.  Now PonyProg will write and verify the code, it will take 1-2 minutes
6.  After the successful write operation PonyProg says "Write successful".
Click OK button to complete the procedure.
7.  Now carefully remove the parallel port programmer from micro-controller board, and press Reset button on development board.

Enjoy Output.


Note :
This is how normal operation of PonyProg takes place.
Remove the programmer from development board to see output.
Your queries and suggestions are always welcome.

Saturday, January 8, 2011

Tutorial 2: Making a development board for ATmega series.

Name: Making a development board for ATmega series.
Application: This is small development board & can be used with ATmega 16/32/64/644 etc.

Requirements and components:
There are 5 baric parts of the development board –
1.       µC holding circuit.
·         General purpose PCB
[If you’re not good with soldering then this can be implemented with two bread board]
·         40 pin IC holder
2.       Power supply circuit.
·         Small sliding switch (with three terminals)
·         Diode 1N4004
·         Electrolytic capacitors -100µF/25V, 10µF/25V
·         IC 7805(or 78L05)
·         Heat sink for 7805(with screw)
3.       Programming pins.
·         This is discussed letter.
4.       Reset circuit.
·         Resistor- 1.2KΩ
·         Electrolytic capacitor- 1uF/10V
·         Micro press button switch(D1/D2 press button switch with two legs)
5.       Crystal circuit.
·         Ceramic capacitors – 22pF
·         Crystal – 16MHz
[Note: Atmel Corporation ships ATmega AVR ICs with internal RC oscillator @ 8MHz. Hence, if you buy a new brand IC from stores then you don’t need to implement crystal assembly. But if you chance the “Fuse bit setting” (just mark the word here!!! we will see this in detail) then you need crystal assembly]
6.       Other
·         Male and female burg strips
·         Wires and soldering accessories.

Connections:
Following diagram shows the connection set up for ATmega16/32
If you see in the diagram all the above parts of circuit are implemented. SV1 and SV2 are the female (or can be male) connectors connected to the port C and port D of IC. One can also connect same connections to the Port A and Port B. But, I recommend that you leave port A as it is. (i.e. don’t connect anything to port A, because this port is used for internal ADC of MegaAVRs.)

One must take care of few things as-
·         Solder the IC base only don’t solder the IC directly to PCB.
·         Watch the position of VCC and GND pins as well as soldered tracks.
·         One can solder the crystal directly but it is good to have female burg at crystal, so that you can change the crystal whenever you need to do so.
Basic connections for development board

One pint to be noted here is that, when you mastered the skills of soldering you can start developing more complex circuit on general purpose PCB. And once u got all things correct on general purpose then you can start develop your own PCB module. But still I recommend the general purpose is better than to have a PCB module as you can modify the circuit on general purpose PCB.
Here are the some of the boards developed by me -



Cost and availability of components:

You can just figure out the components required from above mentioned list and the diagram. Cost of all the components is very less as compared to Atmega ICs.
·         Cost of all components except IC = Rs. 100/- [INR]
·         Cost of IC[ATmega 16/32] = Rs. 250/- [INR]
  
Note: All components will be available @

GALA ELECTRONICS
20, Kalpana Building, 1st Floor, 357,
Lamington Road, Opp. Police Station,
Mumbai-400 007 (INDIA)
Component Division
Tel.: (022) 2386 3549 / 2382 3550
Kit Division
Tel.: (022) 2387 9562
Fax: (022) 2382 3552

Tutorial 1: Parallel port programmer for Atmel MegAVR series.

Application: This programmer can be used with ATmega series. (E.g. ATmega16/32/8/48/88/168.)

Requirements and components:

·         PC with windows xp & parallel port (DB-25 port)
·         Software Ponyrog2000
·         [Note Download any version of PonyProg2000 for Windows 9x/ME/NT/2000/XP distribution]
·         DB-25 male connector and its case
·         FRC cable [Flexible Ribbon Cable] -- with more than 5 strands.
·         Soldering iron & soldering wire.
·         Burg housing connectors (both male & female)

Connections:
DB-25(parallel port) Pin out


Burg housing connectors (male and female)




Connections for Parallel port programmer



Parallel port pins
µC pins
6
8
7
6
9
9
10
7
20-25
11
connectivity table for programmer


Cost and availability of components:
Part name
Quantity required
Cost (for each unit)[in INR]
DB-25 male connector
1
10/-
DB-25 plastic case
1
10/-
FRC cable
1 meter
16/-
Burg housing connectors
(both male and female)
1
(set of 40 pins)
32/-
Total
68/-

Note: All components will be available @

GALA ELECTRONICS
20, Kalpana Building, 1st Floor, 357,
Lamington Road, Opp. Police Station,
Mumbai-400 007 (INDIA)
Component Division
Tel.: (022) 2386 3549 / 2382 3550
Kit Division
Tel.: (022) 2387 9562
Fax: (022) 2382 3552

Note: Above programmer works perfect with ATmega 8/16/32/44/88/168.