Go Down

Topic: Arduino UNO to Atmega8 - with 8Mhz ... how? (Read 1 time) previous topic - next topic

darksir

Hi friends,
I updating sketch from UNO to Atmega8 and I found another problem.

This my sketch is running on 8MHz crystal oscillator. I use HW serial port in my sketch. On 328P everything run OK.

I found on internet boards.txt file modification for ATmega8 with 8MHz internal CLOCK. I added to boards.txt my own definition for ATMega8 with crystal on 8MHz (I changed oscillator fuse bytes for external Xtal).

Now I compiled sketch and run program. I have 19200 bps serial speed definition in sketch, but real speed is only 2400 bps.
Why?

My custom boards definitions :

##############################################################

atmega8noxtal.name=MY ATmega8-noxtal @8MHz

atmega8noxtal.upload.protocol=stk500
atmega8noxtal.upload.maximum_size=7168
atmega8noxtal.upload.speed=38400

atmega8noxtal.bootloader.low_fuses=0xe4
atmega8noxtal.bootloader.high_fuses=0xc4
atmega8noxtal.bootloader.path=atmega8_noxtal
atmega8noxtal.bootloader.file=ATmegaBOOT.hex
atmega8noxtal.bootloader.unlock_bits=0x3F
atmega8noxtal.bootloader.lock_bits=0x0F

atmega8noxtal.build.mcu=atmega8
atmega8noxtal.build.f_cpu=8000000L
atmega8noxtal.build.core=arduino
atmega8noxtal.build.variant=standard

##############################################################

atmega8xtal.name=MY ATmega8-xtal @8MHz

atmega8xtal.upload.protocol=stk500
atmega8xtal.upload.maximum_size=7168
atmega8xtal.upload.speed=38400

atmega8xtal.bootloader.low_fuses=0xff
atmega8xtal.bootloader.high_fuses=0xc4
atmega8xtal.bootloader.path=atmega8_noxtal
atmega8xtal.bootloader.file=ATmegaBOOT.hex
atmega8xtal.bootloader.unlock_bits=0x3F
atmega8xtal.bootloader.lock_bits=0x0F

atmega8xtal.build.mcu=atmega8
atmega8xtal.build.f_cpu=8000000L
atmega8xtal.build.core=arduino
atmega8xtal.build.variant=standard



OK, I accept some transmit errors with use of internal RC oscillator. But why communication speed is only 2400 bps? Is some difference in configuration bits in UNO 328 atmel and Atmega 8 ?

BTW : I use HW ISP programator, I don´t need and use bootloader function.

Many thanks for some help,
Petr

darksir

I tested it still. My arduino with Atmega8 have clock divided by 10 :-(
I selected arduino with Mega8 and internal RC oscillator.
When I make delay(1000); - its take about 10 seconds...

Please, can me someone help?

retrolefty

Quote
Now I compiled sketch and run program. I have 19200 bps serial speed definition in sketch, but real speed is only 2400 bps.
Why?


Quote
I tested it still. My arduino with Atmega8 have clock divided by 10 :-(
I selected arduino with Mega8 and internal RC oscillator.
When I make delay(1000); - its take about 10 seconds...


Sounds like you have the fuse setting for a /8 of the clock frequency. The IDE does not factor that in and it thinks the clock speed is the atmega8noxtal.build.f_cpu=8000000L value you stated in your board entry. So either change the f_cpu value to 1000000L or change the fuse setting to remove that clock /8 setting.

19200 baudrate divided by 8 = 2400 baud.
Lefty

darksir

many thanks for help.
I searched about clock divider in Mega8 fuse, but I dont find it. I think Atmega8 haven´t clock /8 divider. Is it possible?

retrolefty


many thanks for help.
I searched about clock divider in Mega8 fuse, but I dont find it. I think Atmega8 haven´t clock /8 divider. Is it possible?



Well this linked fuse selector app shows a setting for 1, 2, 4, or 8 Mhz internal R/C clock, so it appears it does have clock divider options. So see what your fuse setting are and compare to what the app says you should have.

http://www.engbedded.com/fusecalc

Lefty

darksir

Everything is ok -
FUSES RC osc 8MHz in Arduino with RC oscillator and
FUSES Ext.Crystal Hi freq ...16Kck + 64 :-(

But still arduino is very slow. Any another tip?

i use Atmel ATMEGA 8A-PU in arduino uno board with 8Mhz crystal.

darksir

I testing another thing...

I copied original arduino NG declaration and changed only 16000000 to 8000000 in cpu configuration.
LED blinking is now ok, so I will test it with my sketch and I think everything will be ok.

darksir

RESOLVED----

Mistake was in my custom board define... If I used original arduino setting + change of speed from 16Mhz to 8Mhz everything is Ok now.

Thank you for helping,
Petr

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy