Pages: 1 [2]   Go Down
Author Topic: Use Atmega8/168 with Arduino UNO instead of atmega328p  (Read 4756 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Full Member
***
Karma: 1
Posts: 142
likes to program Arduinos!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WOOOOW!!

THANKS ALOT!

with the part of your boards.txt, it finally working! smiley-grin smiley-grin

Thank you SO much!
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 179
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just picked up a atmega8535  (Hobson's choice at my local hardware shop)

Will comments here about using atmega8 apply to this chip as well?

Thanks.
« Last Edit: July 09, 2012, 12:36:39 am by ardnut » Logged

Norway
Offline Offline
Full Member
***
Karma: 1
Posts: 142
likes to program Arduinos!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to find a bootloader for your atmega chip. If you can find that, I think you'll be OK smiley-wink
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 179
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In comment #4 Duane says:

Quote
I also had to add a new board type to the Arduino IDE to be able to program the standalone Atmega 8's here are my settings from boards.txt -

opti8.name=Arduino Optiboot8

opti8.upload.protocol=arduino
opti8.upload.maximum_size=7680
opti8.upload.speed=115200

opti8.bootloader.low_fuses=0xbf
opti8.bootloader.high_fuses=0xdc
opti8.bootloader.path=optiboot
opti8.bootloader.file=optiboot_mega8.hex
opti8.bootloader.unlock_bits=0x3F
opti8.bootloader.lock_bits=0x0F

opti8.build.mcu=atmega8
opti8.build.f_cpu=16000000L
opti8.build.core=arduino
opti8.build.variant=standard

I use a USB to Serial programmer,

So if I'm following him correctly his prototype board with just the Atmega 8 can be programmed directly using the IDE. The config above ensures the right information for the chip is used in creating the optiboot image.

The usb-serial programmer is presumably a non intelligent hardware interface that converts usb input to ISP serial on MISO MOSI pins. In that case why the need for boot loader?

I'm probably misunderstanding something about what he's doing.

Can anyone put me straight?

thx
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6632
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The config above ensures the right information for the chip is used in creating the optiboot image.
No, you'll still need to build the optiboot image yourself (or use the existing .hex file.)
The info in the boards.txt file is used for compiling the user sketches, uploading the sketches via the bootloader OR via a device programmer, and for the "burn bootloader" command.

Quote
The usb-serial programmer is presumably a non intelligent hardware interface that converts usb input to ISP serial on MISO MOSI pins. In that case why the need for boot loader?
Most programmers are somewhat intelligent.  They do things like check the device type, and convert "high level commands" (like "what device type are you", or "program these 64 bytes of flash at the specified address") to the appropriate  AVR ISP commands on the SPI signals.  All sort of necessary since there's no obvious exact translation between usb (or any other typical desktop PC interface) and SPI.  (at any rate, there wasn't, in the timeframe when Atmel was specifying ISP protocols.)
The bootloader substitutes for the intelligence in the programmer, permitting the AVR to modify its own flash over a dumb data connection.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 179
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, so if I can find a suitable optiboot for 8535 I could install and use it.

The fact that it is parpart or usb/serial driving the SPI lines would not be visible to the chip.

How "dumb" can the data source be ?  It must communicate with the SPI interface and serve the data stream. Am I correct in thinking this could equally be avrdude or the IDE using parport ?
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6632
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The bootloader doesn't use the spi lines at all.  I think there is a bootloader tutorial over on avrfreaks.  You should read it to get a clearer picture of the concept...
Logged

Norway
Offline Offline
Full Member
***
Karma: 1
Posts: 142
likes to program Arduinos!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if i'm going off-topic, but since this my  ( smiley-evil ) post, I'll still ask:

I'm trying to configure the atmega8 to run with its internal oscillator, but I seem to get errors from the compeiler.

I'm using this circuit, but with an 10uF capasitor between amega8-pin1 and Gnd (since I have an arduino UNO):



Since the atmega8 chip already have optiboot 16mhz bootloader installed, should I add an external oscillator (16mhz) when I'm burning an 8mhz bootloader?

And the Boards.txt:
Do some of you have a bootloader and a Boards.txt "file" that are working with the arduino IDE (1.0/1.0.1), making the atmega run at 8mhz?

I've tried several guides, but none of them seems to work.

Have some of you succeeded burning an 8mhz bootloader to an atmega8?

Thanks!

Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 320
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To use the internal oscillator you need to set the fuses for that.  I was directed to this website for their Fuse Calculator
http://www.engbedded.com/fusecalc/

This might help with that.  You then make sure the bootloader was compiled for you oscillator frequency.  You may need to recompile a bootloader but you can cross that bridge if necessary.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you still talking about external oscilator, but where i connect him? (Im trying to burn optiloader to atmega8 16PU)
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 320
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you still talking about external oscilator, but where i connect him? (Im trying to burn optiloader to atmega8 16PU)

I'm not sure what this question means.  Let me see if I can better explain.

The Atmega chips have an internal RC oscillator that has some level of calibration.  I do not know the details.  On a new ATMEGA328, by default it is set to use the internal oscillator of 8MHz which is then divided by 8.  Therefore any code you write for the chip should expect a clock frequency of 1MHz.  This can be changed by altering the fuse bits.  You can alter both the source from internal to external you can also alter the prescaler.

I am told that the internal oscillator is not accurate  enough to do reliable serial communications, however I have not found that to be the case.  There may be a problem if I where trying to do very high speed serial while the chip is very hot or very cold.  I just haven't had a problem.

Now to set up the baud rate, your code will need to know the clock frequency.  Your bootloader will need to set up the baud rate.  Therefore, when the bootloader was compiled, it assumed some clock frequency.  If it were compiled for an UNO it would have assume a 16MHz clock frequency because that is the frequency of the crystal on every UNO board.  So, if you wanted to improve the performance of your UNO, you could replace the 16Mhz crystal with a 20MHz crystal.  But if you do that, you will need a bootloader compiled for 20MHz.  Otherwise, the baud rate will be shifted up by 25% just like the clock frequency.

On the other hand, if you want to use the internal oscillator, it has a maximum frequency of 8MHz.  Your standard bootloader will now have a baud rate half the expected baud rate.  So you need a bootloader that knows the clock frequency is 8MHz. 

When I need to do this, rather than recompile the bootloader, I simply grabbed a bootloader for an older board that was already compiled for 8 MHz.  Something like a Lillypad, although I don't think I used that one.

I hope this helped a little.
Logged

Pages: 1 [2]   Go Up
Jump to: