Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Another push here... Serial on ATmega128

Another push here... Serial on ATmega128

2005-07-06 by Alex De Lara

Hello,

I read this on other answer and was wondering if fuse setting

>> From: "wbounce" <wbounce@...>
>> Subject: RE: [AVR-Chat] help problem in uart 	wbounce1
>> Send Email Send Email
>> I know you go other responses but garbage on the uart 
>> could also mean wrong baud or corrupt fuse settings.


could be part of the reason why I cannot get anything to spit 
out of my ATmega128 serial...

I thought that just using the examples from the datasheet
would suffice to program the usart, baudrate and send a
character...

Also, does the baud rate prescaler use the system clock
(internally) by default ?  Is that correct ? 
(meaning I should  not have to mess up with the fuses -CKSEL- 
currently 0001 - also tried 0100 - both for the internal 
calibrated osc). 
I just wanted to go plain here and see something coming out....
Actually, have installed 4 leds that I can turn or/off/shift
and they are working fine, at least I can see that stuff
is being executed.

The ATmega103-compatibility-mode-fuse is off, meaning that I 
had to use STS to write the UBBRH register. 

(i know, i know... without an scope things are nastier than 
it should ...  but I use the leds outputs as trace points yikes ! )

-Thanks for reading.

Re: [AVR-Chat] Another push here... Serial on ATmega128

2005-07-06 by Dave VanHorn

>
>Also, does the baud rate prescaler use the system clock
>(internally) by default ?  Is that correct ?
>(meaning I should  not have to mess up with the fuses -CKSEL-
>currently 0001 - also tried 0100 - both for the internal
>calibrated osc).

A couple of things to be aware of:

You definitely want the CKOPT fuse checked, in the studio programmer.
Otherwise, you have selected "vittoz" mode oscillator, which has low 
amplitude, and can cause odd timing results, wrong baud rates, and 
all sorts of other grief, unless you know exactly what you are doing, 
and pay a LOT of attention to oscillator design.

If you do a reboot in your code, do it through the WDT. Do not push 
zeroes and do a return.
I forgot about this little nugget a couple days ago, and was 
wondering why my uart wasn't sending anything even though it was set 
up correctly.
A hardware reset gets to parts of the chip that you can't get to by software.

Yes, the default prescaler source is the internal CPU clock, which is 
the crystal, resonator, or whatever you have selected.
Crystals are accurate enough for serial work. Most resonators are as 
well. The internal RC or external RC is not, except under special conditions.

It sounds like you're trying to use the internal RC for serial which 
will bring misery, because it will almost work. Or it will work now, 
and fail later.

Re: Another push here... Serial on ATmega128

2005-07-06 by Alex De Lara

--- In AVR-Chat@yahoogroups.com, Dave VanHorn <dvanhorn@d...> wrote:
> >Also, does the baud rate prescaler use the system clock
> >(internally) by default ?  Is that correct ?
> >(meaning I should  not have to mess up with the fuses -CKSEL-
> >currently 0001 - also tried 0100 - both for the internal
> >calibrated osc).
> 
> A couple of things to be aware of:
> 
> You definitely want the CKOPT fuse checked, in 
> the studio  programmer.
> Otherwise, you have selected "vittoz" mode oscillator, which 
> has low amplitude, and can cause odd timing results, wrong 

I noticed this information on the datasheet as I wasn't really
willing to make any changes on this. So CKOPT is ON.

> If you do a reboot in your code, do it through the WDT.

So far, I'm just using the "push-button" to force the
hard reset. For all God's hardware designs, it should do ;-)

> Do not push  zeroes and do a return.

Though this is a cute trick, I never used it before
(maybe because I could use PCHL on 8085 or EX PC, HL on Z80 grin :-)

> I forgot about this little nugget a couple days ago, and was 
> wondering why my uart wasn't sending anything even though 
> it was set up correctly.
> A hardware reset gets to parts of the chip that you can't get 
> to by software.

Absolutely. And the WDT is excellent for this purpose.
(Well.. that's what is in there for)

> Yes, the default prescaler source is the internal CPU clock, 
> which is the crystal, resonator, or whatever you have selected.

I did not try to select anything special, other than the xtal,
after all, it's already there and I never had any problem in
the past using crystals.

> Crystals are accurate enough for serial work. Most resonators 
> are as well. The internal RC or external RC is not, except 
> under special conditions.

I'll take note of this. Thanks.

> It sounds like you're trying to use the internal RC for 
> serial which will bring misery, because it will almost work. 

I'm already feeling miserable !
Shoot !!! Just checked the CKSEL table on the datasheet 
and 0100 - 0001 does actually select "Calibrated internal 
RC oscilattor" 
Hmm... after a few paragraphs it actually says it ships
with 0001 (the internal rc thing) where I though the default
would be the crystal.
I will test the new settings (1111) tonite. Thanks for the hint !

So, basically just checking 
1) Setting CKOPT on
2) Setting CKSEL 1111
3) Programming the baud rate
4) Enabling TX/RX 
Should get it (finally and hopefulle) going....

Thanks for the pointers. It's always very interesting and
entertaining to hear for others.

-Alex

Re: [AVR-Chat] Re: Another push here... Serial on ATmega128

2005-07-06 by Dave VanHorn

>
>I'm already feeling miserable !
>Shoot !!! Just checked the CKSEL table on the datasheet
>and 0100 - 0001 does actually select "Calibrated internal
>RC oscilattor"
>Hmm... after a few paragraphs it actually says it ships
>with 0001 (the internal rc thing) where I though the default
>would be the crystal.

If so, you'd have to have a crystal attached to program it.
They have their reasons.
Beware though, the osc they select is relatively slow, so setting too 
fast a programming clock will cause errors.
250kHz or slower for new devices, 2 MHz for an 8 MHz system, once 
it's up and running at speed.



>Thanks for the pointers. It's always very interesting and
>entertaining to hear for others.

That's what we're here for. Helping each other find the potholes, 
mostly by yelling when we fall in one :)

Re: [AVR-Chat] Re: Another push here... Serial on ATmega128

2005-07-07 by Kathy Quinlan

Alex De Lara wrote:


> So, basically just checking 
> 1) Setting CKOPT on
> 2) Setting CKSEL 1111
> 3) Programming the baud rate
> 4) Enabling TX/RX 
> Should get it (finally and hopefulle) going....

If not, check and change the Mega103 compat mode, I had a new Mega64 
from the factory last week, and I had to untick the M103 fuse to get the 
serial working (I think I was using Serial Port 1)

Regards,

Kat.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.