Pages: [1] 2   Go Down
Author Topic: Atmega 8 development board  (Read 1322 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 1
Posts: 334
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, I build a development board for atmega 8 last time, and using atmega 8 chip. I used usbasp to upload my code from arduino IDE into the chip. Forr this, I choose my board in arduino IDE as atmega 8

However, how about if I use atmega 328 ? What board should I choose ? Bear in mind that the atmega 328 is fresh( without bootloader ). By the way, I think that if I upload using the USBasp programmer, it does not care whether the chip have the bootloader right ?

I face a problem where when I upload the code from arduino IDE to the chip by selecting arduino UNO board, it came out an error saying that wrong microcontroller being chose. So how ?

Thank you


* Picture1.jpg (41.78 KB, 581x480 - viewed 16 times.)
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

328, or 328P?  Makes a difference.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

328
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, this gets a little 'fun'.
The 328 has different signature bytes than the 328P.
328   0x1E 0x95 0x14
328P 0x1E 0x95 0x0F

The real way around this (doing this from memory, bear with me).

Download a copy of notepad++ so you have a good editor
http://notepad-plus-plus.org/

Find avrdude.conf.  Open it & find 'm328p'

Copy that whole section, call it 'm328' and change the signature bytes per above.
Change anything that ATMega328P to ATMega328.  (no P at the end)
Save that.

Find boards.txt

Find a section that says something like "traditional NG bootloader. "
The NG boards used '168s and internal crystal.

"The initial design of the Arduino LilyPad had a 10-pin ICSP header and used the internal clock on the ATmega168 rather than an external oscillator. The bootloader on the initial design is the traditional NG bootloader. "

So you want to set up like that.
Copy that section, put in your new new board name, and put in the '328 signature bytes and memory limits.

Burn the bootloader so the fuses are set for the internal crystal, and you should be able to load sketches after that.
I've not tried this personally for anything but '1284s witt crystals, but it should get you pretty close.

Come back and ask questions if you get stuck.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Okay, this gets a little 'fun'.
The 328 has different signature bytes than the 328P.
328   0x1E 0x95 0x14
328P 0x1E 0x95 0x0F

The real way around this (doing this from memory, bear with me).

Download a copy of notepad++ so you have a good editor
http://notepad-plus-plus.org/

Find avrdude.conf.  Open it & find 'm328p'

Copy that whole section, call it 'm328' and change the signature bytes per above.
Change anything that ATMega328P to ATMega328.  (no P at the end)
Save that.

Find boards.txt

Find a section that says something like "traditional NG bootloader. "
The NG boards used '168s and internal crystal.

"The initial design of the Arduino LilyPad had a 10-pin ICSP header and used the internal clock on the ATmega168 rather than an external oscillator. The bootloader on the initial design is the traditional NG bootloader. "

So you want to set up like that.
Copy that section, put in your new new board name, and put in the '328 signature bytes and memory limits.

Burn the bootloader so the fuses are set for the internal crystal, and you should be able to load sketches after that.
I've not tried this personally for anything but '1284s witt crystals, but it should get you pretty close.

Come back and ask questions if you get stuck.

What do you mean by the bolded part ? Means I have to create a new text file ? And I cant find something like traditional NG bootloader in the board .txt file ><
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, it means copy that whole section and paste it at the end of the file.
I'll take a look at boards.txt when I get home and see if I can make the NG reference more clear - can't do it from here.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the section I was talking about in boards.txt
Code:
##############################################################

atmega168.name=Arduino NG or older w/ ATmega168

atmega168.upload.protocol=arduino
atmega168.upload.maximum_size=14336
atmega168.upload.speed=19200

atmega168.bootloader.low_fuses=0xff
atmega168.bootloader.high_fuses=0xdd
atmega168.bootloader.extended_fuses=0x00
atmega168.bootloader.path=atmega
atmega168.bootloader.file=ATmegaBOOT_168_ng.hex
atmega168.bootloader.unlock_bits=0x3F
atmega168.bootloader.lock_bits=0x0F

atmega168.build.mcu=atmega168
atmega168.build.f_cpu=16000000L
atmega168.build.core=arduino
atmega168.build.variant=standard
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Okay, this gets a little 'fun'.
The 328 has different signature bytes than the 328P.
328   0x1E 0x95 0x14
328P 0x1E 0x95 0x0F

The real way around this (doing this from memory, bear with me).

Download a copy of notepad++ so you have a good editor
http://notepad-plus-plus.org/

Find avrdude.conf.  Open it & find 'm328p'

Copy that whole section, call it 'm328' and change the signature bytes per above.
Change anything that ATMega328P to ATMega328.  (no P at the end)
Save that.

Find boards.txt

Find a section that says something like "traditional NG bootloader. "
The NG boards used '168s and internal crystal.

"The initial design of the Arduino LilyPad had a 10-pin ICSP header and used the internal clock on the ATmega168 rather than an external oscillator. The bootloader on the initial design is the traditional NG bootloader. "

So you want to set up like that.
Copy that section, put in your new new board name, and put in the '328 signature bytes and memory limits.

Burn the bootloader so the fuses are set for the internal crystal, and you should be able to load sketches after that.
I've not tried this personally for anything but '1284s witt crystals, but it should get you pretty close.

Come back and ask questions if you get stuck.

I do not understand for the bolded part ><
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, find your boards.txt file.

You will see that every section has a line like this:

atmega168.build.mcu=atmega168

You will not find one that end with =atmega328
That name is what ties in with a similar section in avrdude.conf to tell the programmer what it is dealing with.
So maybe you add this to your boards.txt file:
Code:
##############################################################

uno_noP.name=Arduino Uno for Atmega328
uno_noP.upload.protocol=arduino
uno_noP.upload.maximum_size=32256
uno_noP.upload.speed=115200
uno_noP.bootloader.low_fuses=0xff
uno_noP.bootloader.high_fuses=0xde
uno_noP.bootloader.extended_fuses=0x05
uno_noP.bootloader.path=optiboot
uno_noP.bootloader.file=optiboot_atmega328.hex
uno_noP.bootloader.unlock_bits=0x3F
uno_noP.bootloader.lock_bits=0x0F
uno_noP.build.mcu=atmega328
uno_noP.build.f_cpu=16000000L
uno_noP.build.core=arduino
uno_noP.build.variant=standard

avrdude.conf has a 328P section, but not 328 - so you need to copy/paste that section & make a 328 section so  boards.txt can pull in the needed info.
Here's the top of it and what you need to change, the rest of the section gets copied as-is.
Code:
#------------------------------------------------------------
# ATmega328P   <<< remove the P
#------------------------------------------------------------

part
    id = "m328p";  // <<< remove the P
    desc = "ATMEGA328P"; // <<< remove the P
    has_debugwire = yes;
    flash_instr = 0xB6, 0x01, 0x11;
    eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
  0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
  0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode = 0x86;
    # avr910_devcode = 0x;
    signature = 0x1e 0x95 0x0F; // <<< change these to the '328 bytes - maybe just 0F to 14??
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Then I have to burn the bootloader ?

What I initially ask is that without bootloader.
Logged

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

Error


* Untitled.png (283.99 KB, 1366x808 - viewed 12 times.)
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, you don't need a bootloader.
Once you are set up for the '328 chip,
you select the new board type
Tools:Board
select your programmer
Tools:Programmer
then set the fuses
Tools: Burn Bootloader

and then overwrite the bootloaded
File:Upload Using Programmer.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

No, you don't need a bootloader.
Once you are set up for the '328 chip,
you select the new board type
Tools:Board
select your programmer
Tools:Programmer
then set the fuses
Tools: Burn Bootloader

and then overwrite the bootloaded
File:Upload Using Programmer.
if you said I do not need bootloader, then why burn bootloader into thee chip ?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You burn the bootloader to get the fuses set up.

You are not using a crystal? Then there is a change needed in the fuse selections.
I can research that some tomorrow night if someone else does not step in before then. I'm off to bed.

Code:
uno_noP.bootloader.low_fuses=0xff
uno_noP.bootloader.high_fuses=0xde
uno_noP.bootloader.extended_fuses=0x05

uno_noP.build.f_cpu=16000000L
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

I am using the crystal 16MHz
Logged

Pages: [1] 2   Go Up
Jump to: