Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

mAVRISP

An mbed can be used for In-System Programming [ISP] of AVR microcontrollers over a simple three-wire SPI interface.

The current version uses the simple AVR910 protocol to flash the Atmel chip.

The programmer should work with any AVR microcontrollers that support In-System Programming.

Example

This example will run through programming an ATmega328 with the mAVRISP program.

The Arduino IDE can be used to compile code for the ATmega328. The example Blink program that comes with the Arduino IDE can be compiled by first selecting the appropriate target [in this case an ATmega328 (running at the default internal 8MHz oscillator)]:

http://mbed.org/media/uploads/aberk/arduinoboard.jpg

And then selecting Sketch -> Verify/Compile:

http://mbed.org/media/uploads/aberk/arduinocompile.jpg

Under Windows XP the resulting output files can be found in the following directory:

\Documents and Settings\username\Local Settings\Temp\build[number].tmp

This directory will contain a .HEX file with the same name as the sketch. In this case, the name of the file is Blink.cpp.hex. This can be converted to a raw binary file using the free tool hex2bin. Note that you will have to rename the file from name.cpp.hex to name.hex:

http://mbed.org/media/uploads/aberk/hex2bin.jpg

The ATmega328 and mbed are now connected up as follows:

855

Put the AVR binary and the mAVRISP binary [in that order - otherwise the mbed will try to run the AVR binary!] onto the mbed. Ensure that the AVR binary is either appropriately named according to the #define PATH_TO_BINARY in AVR910.h or pass in the name you're using to the program method (see below).

If you open up your favourite serial terminal program you should see the following output when you reset the mbed:

1244

Put an LED and appropriate resistor across digital pin 13 on the ATmega328 and watch it blink!

Hello World!

» Import this programmAVRISP

No documentation found.

Wiring

Atmel Pinmbed Pin
MOSIp5
MISOp6
SCKp7
nRESETp8
VCCVout
AVCCVout
AREFVout
GNDGND

API

» Import this programmAVRISP

No documentation found.

References




calendar Page history
Last modified 09 Sep 2010, by   user Aaron Berk   tag No tags | 1 reply  

1 comment on mAVRISP:

06 Apr 2012

Hi, I really like what you have done here!

One hex2bin conversion can be done with avr-objcopy: avr-objcopy -I ihex foo.hex -O binary foo.bin

I got this working on mega88, but I had to divide ATMEGA328P_PAGESIZE by two. I that way it will give the correct word count and magically it stated to work. Found it on some other forum having this kind of subject.

I'm very thrilled, now I can use mbed as a field programmer. :)

Thank you for your hard work!

Please login to post comments.