Go Down

Topic: Programming ATmega32 using Arduino (Read 10650 times) previous topic - next topic

Midhun

Hi everyone.

I'm new to microcontroller programming. I've done some small projects on breadboard using the Arduino UNO. Now I would like to make a permanent circuit on pcb using an ATmega32 or ATmega328. Using the Atmega328 will make the circuit more complex and I will have to include multiplexers for getting more inputs. So I would like to use the ATmega32 with the Arduino IDE. But I'm a little confused about how to program it. I've got the modified hardware files for the ATmega32 and would like to program it using the USBasp. But right now, I don't have an ATmega32 or any of its 40pin variant and I'm not gonna buy one unless I'm sure that I can program it using the Arduino. Now for my question:

Can I program the ATmega32 using USBasp after making necessary changes in #\arduino\core files and also in 'preferences.txt'? Has anyone tried this before?

Another question is about the arduino bootloader.
What does the 'arduino bootloader' actually do? Is it compatible only with the arduino IDE?

I'm new to this forum and I searched for info but I didn't find exactly what I was looking for. Sorry if I'm posting a repeat thread.

Thanks.


CrossRoads

How about one of the '324 variants? Like 644 or 1284? Lots of them have been used. 40 pin DIPs also, I/O may be more suitable to what you're after.

http://www.atmel.com/dyn/resources/prod_documents/8152S.pdf

Might also look at avr-developers.com, see if the Arduino core files have already been created for that part.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Midhun

Thanks for the info.
I've already got the necessary core files and I would like to know if it is possible to program the 40 pin AVRs using an external programmer like the USBasp with the Arduino IDE.

putyn

as long as you include an ISP header in your pcb that will allow you to connect the usbasp to your board you can reprogram it , there are some people that are not using the bootloader to upload code but using an dedicated programmer

the bootloader "listens" on the serial port for your program and once it receives it, the program will be stored on the micro - its just another way to program your atmel without needing a dedicated programmer but youll need to first burn a bootloader or buy a micro with a bootloader already burned
if you have a dedicate programmer youll be fine without the bootloader :P

CrossRoads

Don't need a header - just a cable adapter (or 1 to 1 cables) to go from AVR ISP programmer to the board's +5, Gnd, Reset, SCK, MISO, MOSI pins.
I used the mdfly.com programmer to program the '1284 on my Bobuino.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Midhun

Found it!

Cytron Technologies has got a good tutorial on how to program arduino using usbasp. Here it is

http://tutorial.cytron.com.my/2011/09/30/how-to-program-arduino-by-using-avr-usbasp-programmer/

I think it should also work with the 40pin AVRs.

CrossRoads

Kind of complicated.

I added this to programmers.txt
Code: [Select]

usbasp.name=MDFLY
usbasp.protocol=usbasp

(PaulS told me about that)

and added this to boards.txt
Code: [Select]

##############################################################
atmega1284p.name=Arduino-Bobuino 1284p

atmega1284p.upload.protocol=stk500
atmega1284p.upload.maximum_size=129024
atmega1284p.upload.speed=38400

atmega1284p.bootloader.low_fuses=0xFF
atmega1284p.bootloader.high_fuses=0xDC
atmega1284p.bootloader.extended_fuses=0xFD
atmega1284p.bootloader.path=Bobuino
atmega1284p.bootloader.file=ATmegaBOOT_1284P_16MHz.hex
atmega1284p.bootloader.unlock_bits=0x3F
atmega1284p.bootloader.lock_bits=0x0F

atmega1284p.build.mcu=atmega1284p
atmega1284p.build.f_cpu=16000000L
atmega1284p.build.core=arduino


Arduino-Bobuino 1284p shows up under Tools:Board,
and
Tools:Burn Bootloader: w/MDFLY is selected as the boot loader.

ATmegaBOOT_1284P_16MHz.hex gets loaded in as the bootloader.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Midhun

How do you upload code into the atmega1284p?
Is it using the MDFLY usb programmer?
Does the Bobuino board has a serial USB interface similar to Arduino?

CrossRoads

I upload sketches just like an arduino, plug in a USB cable & let the FTDI chip convert it to serial.
I only use the MDFLY for burning the bootloader (tho I suppose it could do sketches too).
Bobuino has serial interface just like a Duemilanove, uses the FT232RL chip.
The itty-bitty 8MU2 on the Uno & newer boards is just a little too tricky to solder down!
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up