Pages: [1] 2   Go Down
Author Topic: When is it time to take off the training wheels? And then what, AVR Dragon?  (Read 1556 times)
0 Members and 1 Guest are viewing this topic.
Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And Atmel Studio 6, or is there a better programmer and programming environment?  It seems like it may be hard to beat fifty bucks and free.

P.S.  The fact that I can't press Alt-F, S to save my sketch makes me angry.  I love the Arduino, but the IDE has a lot of little irritations in it coming from Visual Studio.

Thank you.
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

'round the world...
Offline Offline
Faraday Member
**
Karma: 42
Posts: 3222
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well... why would you?

The Arduino hardware and programming environment are good to let go of the training wheels too. Do you still use digitalRead? digitalWrite? AnalogRead()? Do you know how to use those peripherals without Arduino libraries?

Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The fact that I can't press Alt-F, S to save my sketch makes me angry.

Angry? Really? It's just a programming environment. I don't complain because nothing uses ctrl-ks to save.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   I had the same idea myself recently, I had been building lots of standalone Arduinos that were embedded in time critical applications however when I installed AVR Studio it looked like I would need to learn a new set of libraries for simple things like millis and serial output. Being too old to learn yet another environment I returned to Arduino on the basis that I can get code out very quickly and easily and if I do ever need to optimise anything to the nth degree I can use all the time I have saved using the familiar Arduino environment to do so (so far I have not needed to).

If you go commit to AVR Studio, let us know how you get on and if there are any killer benefits that we should not be living without.

Duane B

rcarduino.blogspot.com




 
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

P.S.  The fact that I can't press Alt-F, S to save my sketch makes me angry.  I love the Arduino, but the IDE has a lot of little irritations in it coming from Visual Studio.

Isn't Ctrl+S easier anyway? And you can specify an external editor if you want to.
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you go commit to AVR Studio, let us know how you get on and if there are any killer benefits that we should not be living without.

OK, I took a few hours and bit the bullet today and it all worked out.  I bought an Dragon from Digikey a couple of weeks ago and also some ATTiny85s and ATTiny88s because I knew I wanted to do this.  This is basically how it is done:

1.  Solder a ZIF socket and some headers to the Dragon.   This guy gives a good tutorial:  
2.  Jumper the Dragon for In System Programming for the particular chip you are going to use.  This document gives the correct jumpers under "Devicesheet: ATtiny25, ATtiny45, ATtiny85", "In System Programming and debugWIRE emulation": http://people.ece.cornell.edu/land/courses/ece4760/AtmelStuff/dragon.pdf
3.  Download Atmel Studio 6.  Install it.
4.  Plug in the Dragon.  The New Hardware dialog comes up and Windows seems to know what it is.  You want to do this after installing Atmel Studio otherwise I don't think Windows will know what a Dragon is.
5.  Run Atmel studio.  Make a new project.  You just let it know what chip you are programming for.  Enter your code, compile it.  Then you have to go to the programmer, select the .elf file that the compilation created, put your chip in the ZIF socket, and program it.  I was able to use the standard fuse settings.

My test code was a modification of the first project in tinyAVR Microcontroller Projects for the Evil Genius.  I simplified it, it alternately blinks two LEDs.  That is all.  Here is the project:



Here is the code:

Code:
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>

int main() {
  DDRB |= 1<<2|1<<3;
  PORTB |= 1<<2|1<<3;

  while (1) {
    PORTB &= ~(1 << 3);
    _delay_ms(300);

    PORTB |= (1 << 3);

    PORTB &= ~(1 << 2);
    _delay_ms(300);

    PORTB |= (1 << 2);
  }
}

Benefits?

1.  No problem programming an ATtiny (an 81 CENT 8KB AVR if you buy 25 at Digikey, which I did).  I keep hearing the Arduino envornment has problems with these, especially the ones without a lot of memory.
2.  The code was 148 bytes total in length.
3.  You can debug your project!  At least, I am told you can and the video guy above shows how it works.  I am having trouble right now making that happen but I bet I can figure it out.  To me, this is huge.  This is an ISP programmer which means you can program and debug the circuit on your breadboard, or even on a soldered circuit board.  That means you get to debug in your real hardware environment with all your inputs and outputs live.  You can put a breakpoint on the code that handles your input devices and when you push a button, turn a rotary encoder, etc, it will hit the breakpoint.  Now that is pretty cool.  I just used the ZIF socket tonight because it was the easiest thing to do.  Next time, breadboard with an nunchuck connected!
4.  Street cred?  smiley-grin
5.  Last, but not least, Alt-F,S works like a charm, for reasons which, at this moment, must be all too obvious...
« Last Edit: June 24, 2012, 01:35:42 am by JoeN » Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I made up a small "jig" board which pre-connects the jumpers for the board you want to program. This is particularly useful for the larger chips like the Atmega328 which have quite a few pins you have to jumper. Then when you want to use the programmer you just shove the board onto it to make the connections.

Underneath:



Top:



Ready to use:



It's useful for the smaller chips, but I still write the code in the IDE.

Compiled in the Arduino IDE (1.0.1) the sketch you posted above gives this:

Code:
Binary sketch size: 144 bytes (of a 8192 byte maximum)

That is 144 bytes compared to your 148. So don't get too excited that you are saving heaps of program memory.

As for the debugging, well let us know how that goes. Personally I haven't been motivated to attempt to use it yet.

The ZIF socket is a good idea. When testing it is nice and quick to remove the chip from the programmer and drop it into a test board (also with a ZIF socket) until it is all debugged.
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Compiled in the Arduino IDE (1.0.1) the sketch you posted above gives this:
Code:
Binary sketch size: 144 bytes (of a 8192 byte maximum)

That is interesting, sort of surprising to me, but to use the Arduino, aren't you immediately losing 1K or something like that for the bootloader?

I have seen something like your pre-made jumper board on Hack A Day when I was researching all of this prior to actually doing the work tonight:

http://hackaday.com/2009/09/26/avr-dragon-wiring-alternative/

That does look like a good idea if you are going back between a few AVR chips that you know you will stick to.  I have a pretty good idea I like these tiny85 chips.  The number of pins is limited, but the RAM and flash should be OK for a lot of applications and they are so incredibly cheap.

The other choice is buy another Dragon and jumper it up to your other configuration(s).  The tradeoff is going to be probably more time to do the board but less cost.  Then again, the Dragon is really quite reasonable at fifty bucks.
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is interesting, sort of surprising to me, but to use the Arduino, aren't you immediately losing 1K or something like that for the bootloader?

First, the Optiboot loader is only 512 bytes.

Second, to compare apples with apples, I was compiling in the IDE, and then using the Dragon to upload. So I didn't need a bootloader.

You don't have to use a bootloader, and indeed the smaller chips don't support one anyway.

If you compile in the IDE with verbose output, you get to see the location of the .hex file. Just copy and paste that into the "file to upload" box for the Atmel Studio uploader, and it uploads the .hex file from the IDE. Pretty simple, because the name won't change for one session.

When I was testing stuff on the AtTiny85 I hit the "Verify" button in the IDE, which produces the .hex file, switched to the Atmel Studio and then hit the Upload button. Just a couple of clicks and the chip was programmed. Pull it out, put it into the testing board, and test.
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is interesting, sort of surprising to me, but to use the Arduino, aren't you immediately losing 1K or something like that for the bootloader?

First, the Optiboot loader is only 512 bytes.

Second, to compare apples with apples, I was compiling in the IDE, and then using the Dragon to upload. So I didn't need a bootloader.

You don't have to use a bootloader, and indeed the smaller chips don't support one anyway.

If you compile in the IDE with verbose output, you get to see the location of the .hex file. Just copy and paste that into the "file to upload" box for the Atmel Studio uploader, and it uploads the .hex file from the IDE. Pretty simple, because the name won't change for one session.

When I was testing stuff on the AtTiny85 I hit the "Verify" button in the IDE, which produces the .hex file, switched to the Atmel Studio and then hit the Upload button. Just a couple of clicks and the chip was programmed. Pull it out, put it into the testing board, and test.

Thanks for that information.  I did not know that.  The fact is, I just want another tool here and I am interested in the debugging aspect.  I purposefully titled this thread a little bit provocatively and maybe I should not have done that.  I love the Arduino boards that I have bought so far and I am going to use AVR Studio and the Arduino system both as tools in the chest.  Also, and I am not going to do this for a while because I have enough ideas on my plate already, I would like to experiment with Atmel's ARM microcontrollers in the future.  It seems this is something that Studio 6 apparently supports, though it looks like it may require a different programmer.
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No offence taken. smiley

Have fun, and if you find anything useful, please let use know. Like, is the debugger worth the effort, or not?
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Nick,

Do you have an overview of how the high voltage programmer works ? I have locked myself out of 3 or 4 ATMega8's and understand that high voltage programming is one method to get back in.

Duane B
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't made one, but from the datasheet (page 300) you apply +12V to the /RESET pin (this is the "high voltage" part).

This turns the chip into "parallel programming mode" where the normal IO pins are reconfigured to have different meanings. The programming works in the absence of any clock (well, you supply the clock) and regardless of the fuse settings. You can't read back a protected program, but you can change the fuse bits to allow SPI programming if disabled, and unprotect the chip (which erases it).
Logged

Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 246
Code Monkey
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The fact that I can't press Alt-F, S to save my sketch makes me angry.

Angry? Really? It's just a programming environment. I don't complain because nothing uses ctrl-ks to save.

:wq doesn't work either.
Logged

I yield() for co-routines.

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Nick,

Do you have an overview of how the high voltage programmer works ? I have locked myself out of 3 or 4 ATMega8's and understand that high voltage programming is one method to get back in.

Duane B

I would suggest you read the document I linked earlier:

http://people.ece.cornell.edu/land/courses/ece4760/AtmelStuff/dragon.pdf

It says this...

Quote
High Voltage Serial Programming Description

Low pin count AVR devices do not have enough IO pins to support the full Parallel
Programming interface. These devices instead use HVSP programming, which is a serial
version of the Parallel Programming interface.

Important!

Extreme care should be taken if using HVSP mode to program a AVR device on an external
target. The HVSP lines do not have level converters, so it is important that the target board
is powered by the AVR Dragon VCC header, and not using another power supply. In
addition the AVR Dragon will apply 12V to the reset pin, so it is important that the target
board is designed to handle 12V on this line.

To avoid damaging the Target Board, the AVR Dragon or both, it is recommended to only
use HVSP mode on devices placed in the 28/40 pin DIP socket on the AVR Prototype area
on the AVR Dragon.


Parallel Programming Description

High pin count AVR devices support the full Parallel Programming (PP) interface. This
interface offer high speed programming, and also support programming all fuse and lock
bits in the AVR Device.

Important!

Extreme care should be taken if using PP mode to program a AVR device on an external
target. The PP lines do not have level converters, so it is important that the target board
then is powered by the AVR Dragon VCC header, and not using its own power supply. In
addition the AVR Dragon will apply 12V to the reset pin, so it is important that the target
board is designed to handle 12V on this line.

To avoid damaging the Target Board, the AVR Dragon or both, it is recommended to only
use PP mode on devices placed in the 28/40 pin DIP socket on the AVR Prototype area on
the AVR Dragon.


The way I read this, you can do it with the Dragon in the prototype area once you have mounted a ZIF socket.  This document gives the correct wiring diagram for the HVSP and PP programming modes for all devices that are supported.

So with a Dragon with a ZIF mounted and Atmel Studio 6 installed, you should be able to jumper it correctly and program it - just select the HVSP or PP programming mode on the programming screen when you get there.
« Last Edit: June 24, 2012, 08:56:17 pm by JoeN » Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Pages: [1] 2   Go Up
Jump to: