PDA

View Full Version : avr problem!!



firebolt_4u
01-05-2006, 01:29 AM
hi
i have recently graduated to avr n using ATMEGA8515.
i recently faced a problem.
i am trying to interface a servo with the avr uc.
i used futaba servoo
with on time 1-2ms n off time 20 ms
i used delays to generate pwm as i am nt so comfortable with programming n the libc of avr.
now i analysed the signal using an occiloscope
and i saw that the on time was actually coming out to be 25 ms n off time was also too alrge
how cn this happen..
since i had given a delay of 2 ms for on time
the avr has internal clock of 1Mhz
i have an ocillator of 8 mhz how do i change the fuse settings?
i
is this the problem?
please advice
also where cn i learn basics of programmin the avr uc in c with max examples.
thanks

devpriya
01-05-2006, 09:23 PM
Hey firebolt, even I have faced the same problem when I started with AVRs.

Most probably your fuse settings are not allowing you to select the clock you wish, and thats what you have also observed.

So if you are using AVRdude for programming then I can help you a bit.

write the command

avrdude -p m8515 -c bsd -t my programmer is BSD type , i dont > know yours !

you will get a message that your AVR device is initialized, then go to the prompt it gives you and take a dump of your Low fuse and High fuse bits by writing
> d lf
> d hf

see if it matches with the fuse combination in the data sheet ?

if not then change them by writing

> w lf 0x00 what ever value you wish after this much
> w hf 0x00 <your value>

example -

>w lf 0x00 0xe1 -> this will set low fuse bits to e1

if you are using some other programmer then do tell me full configuration of your software and hardware as well as your operating system.

Lets see if can help you in someway !!!!
:D

firebolt_4u
01-06-2006, 12:55 AM
hi
thanks a lot!!
i am also using bsd PPT programmer.
i used the comamnd line options u specified..and it says u cnt change the fuse bits as it is in safe mode and use option u for changin but it shows the avrdude prompt on typing d lf and h lf it gave both to be 0000 ff.[b]
i am using an 8Mhz external oscilaltor
now the data sheet talks of sumthing CKSEL3..0 and its range 1111-1010
and of CKOPT FUSE SETTINGS..WHAT R THESE??
also u said sumthing abt setting fuse pins to e1..wats that?..
pardon me bt i aint that familiar with the programmin and electronic symbols!
what should be the fuse settings required to get the correct PWM.?

was the scaling of the signal due to non availability of external clock?

also cn u send some links where i can see some programs like ir transmitter reciever interfacing..motor control as i plan to use avr uc extensively in the future..and learn its coding in c!!

i would be highly obliged..!!
thanks in advance

adios

devpriya
01-06-2006, 01:39 AM
i used the comamnd line options u specified..and it says u cnt change the fuse bits as it is in safe mode and use option u for changin but it shows the avrdude prompt on typing d lf and h lf it gave both to be 0000 ff.[b]

Hey it happens when you use the AVRdude supplied with WinAVR, try downloading AVRdude separately and use it , your safe mode problem will not be there anymore.


now the data sheet talks of sumthing CKSEL3..0 and its range 1111-1010
and of CKOPT FUSE SETTINGS..WHAT R THESE??
also u said sumthing abt setting fuse pins to e1..wats that?..

Look even I am experimenting too, now what i said about e1, was just an example that this could be one of the values of the fuse bits.

You do one thing , go to the fuse programming part in the data sheet and change the fuse values to the default one, I think the default one is 8MHz for Mega8515, so you dont even need an external crystal.

It will give you fairly decent PWM with internal clock and moreover in applications like motor control we never need that much of precision , so we can always do away with internal clocks , so why to go for external crystals.

Just set the bits to their default values if the default clock is 8MHz otherwise refer the datasheet for 8MHz value and set the values accordingly.

Those CS3...0 bits are the one which select the clock speeds, just go thorugh their tables.

Dude I just can't go through the data sheet right now because my exams are going on. So if you can just give me some snap shots of the screen when you are using AVRdude and the messages you are getting I can help you.

If possible send me the code too.........You can post all this in the forum itself , let others help you out too.

For sample programs , ask Vikas he can give you links or search in AVRfreks.net

From my side if you wish I can edit your program if you post it here :)

devpriya
01-06-2006, 01:42 AM
i used the comamnd line options u specified..and it says u cnt change the fuse bits as it is in safe mode and use option u for changin but it shows the avrdude prompt on typing d lf and h lf it gave both to be 0000 ff.[b]

Hey it happens when you use the AVRdude supplied with WinAVR, try downloading AVRdude separately and use it , your safe mode problem will not be there anymore.


now the data sheet talks of sumthing CKSEL3..0 and its range 1111-1010
and of CKOPT FUSE SETTINGS..WHAT R THESE??
also u said sumthing abt setting fuse pins to e1..wats that?..

Look even I am experimenting too, now what i said about e1, was just an example that this could be one of the values of the fuse bits.

You do one thing , go to the fuse programming part in the data sheet and change the fuse values to the default one, I think the default one is 8MHz for Mega8515, so you dont even need an external crystal.

It will give you fairly decent PWM with internal clock and moreover in applications like motor control we never need that much of precision , so we can always do away with internal clocks , so why to go for external crystals.

Just set the bits to their default values if the default clock is 8MHz otherwise refer the datasheet for 8MHz value and set the values accordingly.

Those CS3...0 bits are the one which select the clock speeds, just go thorugh their tables.

Dude I just can't go through the data sheet right now because my exams are going on. So if you can just give me some snap shots of the screen when you are using AVRdude and the messages you are getting I can help you.

If possible send me the code too.........You can post all this in the forum itself , let others help you out too.

For sample programs , ask Vikas he can give you links or search in AVRfreks.net

From my side if you wish I can edit your program if you post it here :)

devpriya
01-07-2006, 05:50 PM
Hey firebolt i havent got any response from you......! Did your uC give you the correct PWM ? Were you able to change the fuse bits ? Do give me feedback .