free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
amiicool
Tue Jul 15 2008, 01:42PM
 User Offline
Registered Member #9062
Joined: Tue Jul 15 2008, 12:27PM

Posts: 10
Thanked 0 times in 0 posts
Hello
i am new to avr microcontrollers. i compiled the following code using CVAVR by its make command. i also set clock speed to 4 MHz using the configure dialogue box. It runs fine when i Simulate it on Proteus, but practically after burning, controller blinks the LEDs slower than actually they should.

/*****************************************************
Project : LED Flasher
Chip type : ATmega32
Clock frequency : 4 MHz
*****************************************************/

#include<mega32.h>
#include<delay.h>
#define xtal 4000000

int i;

void main (void)
{
PORTB=0xFF;
DDRB = 0xFF;

while(1)
{

for(i = 1; i <= 128; i = i*2)
{
PORTB = ~i;
delay_ms(100);
}

for(i = 128; i > 1; i = i/2)
{
PORTB = ~i;
delay_ms(100);
}

}

}
------------------------------------------------------------------------------
i am using AVR ISP programmer with parallel interface,
i have attached the schematic of the AVR ISP programmer
Software for burning is Pony Prog.







VizeGuY
Back to top


Ajay
Wed Jul 16 2008, 08:22AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3753
Thanked 696 times in 655 posts
well there is lot of difference in practical and simulation, i think you know it now

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


amiicool
Thu Jul 17 2008, 09:20AM
 User Offline
Registered Member #9062
Joined: Tue Jul 15 2008, 12:27PM

Posts: 10
Thanked 0 times in 0 posts
Thank u Sir but wats the remedy,
Please help

VizeGuY
Back to top


pdi33
Thu Jul 17 2008, 11:12AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
well ami,
to match the simulation in real time, u have to keep the CPU load of the simulation lower than 100%. reducing ur uC frequency to a lower value definetely reduces the CPU load. I think it als depends upon ur system configuration because ur software ran pretty smoothly in my system ( maybe because it is an AMD athlon 4400+ 64 bit CPU+ 2B RAM ).
So do not spend time trying to speed up the simulatin. just co-ordinate ur output with the time base shown on the bottom of the simulation screen and anyways, it will run smoothly in real time on hardware so why worry?

* inspired to develop,developing to inspire *
Back to top


MATHIVANAN
Thu Jul 17 2008, 11:54PM
 User Offline
Registered Member #2569
Joined: Wed Jul 25 2007, 05:21AM

Posts: 57
Thanked 4 times in 4 posts
do you check the fuse bit settings. other wise it will use internal oscillator and it works very slow

I respect others the same way i expect from others.
Back to top


amiicool
Fri Jul 18 2008, 03:23AM
 User Offline
Registered Member #9062
Joined: Tue Jul 15 2008, 12:27PM

Posts: 10
Thanked 0 times in 0 posts
Simulation runs fine, CPU load varies between 50% - 60%.
The problem i have is that practically after burning the AVR, The LEDs Blink slower than 0.1ms, which i have programmed it for.
i used a 4MHz Crystal.

I want to Know if have missed any register defination in my programming which selects the external clock for AVR that is 4MHz Crystal. Or is there a problem while burning the AVR, because i simply compiled the program with CodeVisionAVR and burned the Hex file to the AVR using PonyProg.

VizeGuY
Back to top


Arun Kumar V
Fri Jul 18 2008, 06:50AM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 452
Thanked 190 times in 160 posts
Hello Amiicool,

i hope you have set the clock fuse to external Hi-freq Crystal while burning the hex in pony prog.








Arun


Back to top



This post has been thanked 1 time
 amiicool 
pdi33
Fri Jul 18 2008, 08:00AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
here are the clock fuse bits to be set for different oscillator options
(taken from the ATMEGA datasheet)


take care that checking the box implies zero and leaving it blank implies 1 in ponyprog fuse settings.
default valueof CLKSEL fuses when shipped is 0001 i.e. 1MHZ internal oscillator.
to change it to external 4mhz oscillator change it to settings highlighted in red.



* inspired to develop,developing to inspire *
Back to top


amiicool
Mon Jul 21 2008, 12:02PM
 User Offline
Registered Member #9062
Joined: Tue Jul 15 2008, 12:27PM

Posts: 10
Thanked 0 times in 0 posts
Thanks Arun
and Thanks Pdi33

I did dot set the fuse bits.

would please tell me in detail on how to set the fuze bits for 4Mhz external Xtal on ponyProg.

VizeGuY
Back to top


pdi33
Mon Jul 21 2008, 08:29PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
hi ami,
try the following steps for changing the fuse bits:
1. connect the uC in ISP mode.
2. open ponyprog and click on the 'securityand configuration bit' in the 'command' menu.
3. the dialogue box (as shown in previous post of arun ) will appear. here press the read button. this will read the security /configurastion bits of ur uC and update the various boxes (checked/unchecked). If ur uC is fresh(i.e. if u are changing this for the first time), then the default value of the uC is 1MHZ internal oscillator. i.e. the CLKSEL fuses will be in this order:
clksel3 ------> 0 ----- > checked
clksel2 ------> 0 ----- > checked
clksel1 ------> 0 -----> checked
clksel0 ------> 1 ----- > unchecked
SUT1.1 --------> 1 ----- > unchecked
SUT1.0 -------> 0 ------> checked

now, for external crystal of 4MHz, u need to change the bits to the following values:
clksel3...0 -----> 1111
SUT1.1-1.0 -----> 1111
CKOPT ------> 1

so, uncheck all these boxes to bring them to 1 and press write button.

that is all.
good luck.


* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 amiicool 
Go to page  [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems