Ive read the instructions on how to use the usbtinyisp on here:
http://www.ladyada.net/learn/avr/
and http://www.ladyada.net/make/usbtinyisp/use.html
but the instructions seem too general (which is good but not for a beginner like me). is there a simple guide that teaches how to write a code to the atmega168 on the arduino? or how to read the code from that chip?
thanks.
new to external programmers
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: new to external programmers
first tryto see if avrdude recognizes your chip.
next, if you've got a brand new chip you'll have to burn the fuses. the fuse settings will depend a whole lot on how your board is setup. as it comes from the factory the chip will be running at 1MHz on its internal oscillator. chances are you'll want to change at least the low fuse byte. to burn the low fuse change the string zz in the following to the fuse settings you require.
to burn your program
Code: Select all
avrdude -c usbtiny -p m168 -v
next, if you've got a brand new chip you'll have to burn the fuses. the fuse settings will depend a whole lot on how your board is setup. as it comes from the factory the chip will be running at 1MHz on its internal oscillator. chances are you'll want to change at least the low fuse byte. to burn the low fuse change the string zz in the following to the fuse settings you require.
Code: Select all
avrdude -c usbtiny -p m168 -u -U lfuse:w:0xzz:m
Code: Select all
avrdude -c usbtiny -p m168 -U flash:w:program.hex
-
- Posts: 235
- Joined: Tue Dec 04, 2007 1:22 pm
Re: new to external programmers
thanks, does the arduino need to be powered by the usb cable? and in what direction do i insert the 6 pin-cable of my usbtinyisp to the arduino?
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: new to external programmers
Take a look at the schematics of the programmer and the arduino to see how they connect then read the instructions.
-
- Posts: 235
- Joined: Tue Dec 04, 2007 1:22 pm
Re: new to external programmers
thanks, i could do the first command you specified here without a problem, the 2nd one i didnt need i guess, im writing directly to the arduino. what language should be the program.hex file? (and where does it have to be located?) does it have to be with the void_start and the void_loop that the arduino has?mtbf0 wrote:to burn your programCode: Select all
avrdude -c usbtiny -p m168 -U flash:w:program.hex
thanks.
p.s,
when i typed the command "avrdude -c usbtiny -p m168 -U flash:r:prog.hex:i" to try to read what is on the microcontroller all i got in the file itself is ":00000001FF" is there an option to see the cpp source code?
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: new to external programmers
you write a program in c, assembly, basic, in "arduino", whatever... compile and link it and the hex file is what you've got when you're donedragonuv wrote:thanks, i could do the first command you specified here without a problem, the 2nd one i didnt need i guess, im writing directly to the arduino. what language should be the program.hex file?mtbf0 wrote:to burn your programCode: Select all
avrdude -c usbtiny -p m168 -U flash:w:program.hex
it ought to be in your working directory at the time you summon avrdude(and where does it have to be located?)
only if you're building it in the arduino environment.does it have to be with the void_start and the void_loop that the arduino has?
not a chance. unless you've got the source code lying around.when i typed the command "avrdude -c usbtiny -p m168 -U flash:r:prog.hex:i" to try to read what is on the microcontroller all i got in the file itself is ":00000001FF" is there an option to see the cpp source code?
-
- Posts: 235
- Joined: Tue Dec 04, 2007 1:22 pm
Re: new to external programmers
so why does it have a read option ?mtbf0 wrote:not a chance. unless you've got the source code lying around.
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: new to external programmers
so the binary on the mcu can be compared to the hex file to verify it's validity. so you can retrieve the binary from the chip and copy it to another. because the developers had an extra "r" lying around when they were figuring out upload options.dragonuv wrote:so why does it have a read option ?mtbf0 wrote:not a chance. unless you've got the source code lying around.
-
- Posts: 235
- Joined: Tue Dec 04, 2007 1:22 pm
Re: new to external programmers
thanks for the great answers :)
when i was studying assembly last year i learned that the computer translates from assembly language into binary and i guess the .hex file contains all the assembly instructions. is it true that a sequence of binary code can be translated into an assembly instruction on any microcontroller ? or each microcontroller has its own sequence of binary code which is translated to an instruction (mov ax,01 for example)?
thanks
p.s.
can any microcontroller be programmed? (not necessarily with avr's, but in general)
when i was studying assembly last year i learned that the computer translates from assembly language into binary and i guess the .hex file contains all the assembly instructions. is it true that a sequence of binary code can be translated into an assembly instruction on any microcontroller ? or each microcontroller has its own sequence of binary code which is translated to an instruction (mov ax,01 for example)?
thanks
p.s.
can any microcontroller be programmed? (not necessarily with avr's, but in general)
-
- Posts: 373
- Joined: Tue Mar 06, 2007 11:51 pm
Re: new to external programmers
Yeah, microcontrollers do need to be programmed to do stuff, though that programming could be hard-coded from the factory and never be able to be changed.
And yes, the binary of the AVR translates directly into assembly instructions. For example, the string corresponds to
And yes, the binary of the AVR translates directly into assembly instructions. For example, the string
Code: Select all
0C01
Code: Select all
ADD R0, R1
-
- Posts: 235
- Joined: Tue Dec 04, 2007 1:22 pm
Re: new to external programmers
my question was that if for example the hex number 0c01 translates to the assembly instruction "ADD R0, R1" on every cpu, but my teacher said its not.
is there a list of each assembly instruction that translates to its equvalent in binary\hex (on avr µ-controllers).
so i can translate in assembly the hex file
is there a list of each assembly instruction that translates to its equvalent in binary\hex (on avr µ-controllers).
so i can translate in assembly the hex file
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: new to external programmers
so, you want to reverse engineer somebody else's device. you're probably not going to have a whole lot of fun unless your a very patient individual. and very motivated.
for the instruction set, see the data sheet for the avr you're dealing with.
then try googling "avr disassembler" or something similar. i make this rather unhelpful suggestion because i've never tried this and can offer no helpful suggestions. when i crave frustration i only have to try getting my own code to work.
even with a disassembled file it may be amusing trying to figure out what's going on, especially if the program was originally written in a higher level language.
for the instruction set, see the data sheet for the avr you're dealing with.
then try googling "avr disassembler" or something similar. i make this rather unhelpful suggestion because i've never tried this and can offer no helpful suggestions. when i crave frustration i only have to try getting my own code to work.
even with a disassembled file it may be amusing trying to figure out what's going on, especially if the program was originally written in a higher level language.
Please be positive and constructive with your questions and comments.