Flash the ATMEGA32

Transcription

Flash the ATMEGA32
How to ? /
Flash the ATMEGA32
Français
La programmation du microcontrôleur n’est pas très compliquée mais elle nécessite un
minimum d’attention. Elle peut se faire directement sur la platine du Monome grâce aux
protocoles JTAG (connecteur présent sur la carte originale du Monome) ou ISP (In System
Programmer). J’attire votre attention sur le fait que ces deux protocoles utilisent le même
connecteur 2x5 broches et donc qu’ils sont très souvent confondus. Néanmoins il faut veiller
à bien distinguer les deux car l’utilisation d’un programmateur ISP branché à un connecteur
JTAG court-circuite l’alimentation. Pour ma part, j’ai choisi de décrire la programmation ISP
pour sa simplicité.
Matériel nécessaire :
-
Un programmateur ISP : pour ma part j’ai utilisé le programmateur parallèle décrit
par Christian Tavernier et que l’on retrouve sur de nombreux autres sites.
Le schéma est dispo ici :
http://www.tavernier-c.com/programmateur_atmel.htm
Mon PCB est dispo ici :
http://antoine.grall.free.fr/docs/CI_progatmel.zip
-
Un logiciel pour la programmation : pour ma part j’ai tuilisé Pony Prog qui est un
logiciel gratuit et très bien fait, dispo notamment ici :
http://www.lancos.com/prog.html
-
Le fichier INPOUT.DLL peut être nécessaire quand il s’agit de dialoguer avec le port //.
Il doit être collé dans le dossier de Pony Prog et dans les dossiers « Windows »,
« System » et « System32 ». Il est facilement trouvable sur le net. Pour ma part je
n’en ai pas eu besoin.
-
Le programme « 40h.hex » gracieusement donné par Monome et dispo dans cette
archive :
http://monome.org/here/monome40h_firmware.tar.gz
Le programmateur est on ne peut plus simple à
fabriquer donc je ne m’étalerais pas dessus. La LED est
en option puisqu’aucune broche de l’ATMEGA ne la
pilote.
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm
Celui-ci terminé, il suffit de raccorder les 6 broches nécessaires à la programmation in-situ :
GND
VCC
MOSI =>
MISO =>
SCK =>
RESET =>
pin6 de l’ATMEGA
pin7 de l’ATMEGA
pin8 de l’ATMEGA
pin9 de l’ATMEGA
Il reste alors à connecter le programmateur à un port LPT et à brancher le câble USB de la
carte supportant l’ATMEGA pour l’alimenter. Oublier d’alimenter l’ATMEGA pendant sa
programmation peut l’endommager fortement…
Le logiciel Pony Prog nécessite lui, une petite configuration, que je vais décrire ici :
Etape 1 : Après l’avoir installé et ouvert, la première chose à faire est de choisir, dans la
fenêtre principale, le type de composant à programmer à savoir dans la famille des AVR,
l’ATMEGA32 :
Etape 2 : Il faut ensuite choisir le type de programmateur employé (parallèle, AVR ISP I/O),
dans le menu « Setup » => « Interface Setup ». Un clic sur « Probe » permet de le détecter.
Etape 3 : Toujours dans le menu « Setup », il faut calibrer le logiciel grâce au menu
« Calibration », en veillant à fermer tous les autres programmes en cours d’exécution.
Etape 4 : On peut ouvrir le programme FLASH « 40.hex » donné sur le site Monome.
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm
Etape 5 : Il reste à lire et à reprogrammer les fusibles de l’ATMEGA. Ceux-ci sont typiques de
la famille AVR et permettent un certain nombre de réglages pour le composant. Ils doivent
êtres configurés correctement sous peine de ne plus pouvoir utiliser l’ATMEGA comme
souhaité.
Accéder au menu « Command » => « Security & Configuration Bits ». L’icône « Read »
permet d’afficher la configuration actuelle des fusibles et permet par la même, de vérifier
que le composant est bien reconnu. Il faut alors cocher ou décocher les fusibles pour obtenir
la configuration suivante :
On peut alors reprogrammer les fusibles en cliquant sur « Write ».
NOTA : cette configuration peut être retrouvée sur le site :
http://www.engbedded.com/fusecalc/
Il suffit de choisir le bon composant et d’inscrire les deux valeurs EE et 00 dans les deux
cases tout en bas de la fenêtre. Ces deux valeurs sont données par Monome dans le
Makefile.
Etape 6 : Les fusibles programmés, il reste à envoyer le programme dans l’ATMEGA en
cliquant dans le menu « Command » sur « Write program flash ».
A l’issue de la programmation, on peut déconnecter le programmateur. La broche RESET de
l’ATMEGA doit être reliée au VCC (mettre un point de soudure entre les deux pattes).
Le Monome a désormais un cœur battant !
Sites utiles : monome.org - tavernier-c.com - silicium628.fr
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm
English
Flashing the ATMEGA32 isn’t a difficult operation but it requires some attention. It can be
flashed using the JTAG protocol (2x5 connector on the original Monome board) or using the
ISP protocol. The ISP protocol uses the same 2x5 connector but is very different. Make sure
you don’t mix the two protocols. I chose to describe a simple way to flash the Monome
ATMEGA32 with a very cheap DIY ISP programmer. You’ll need :
-
An ISP programmer :
Schematic here :
http://www.tavernier-c.com/programmateur_atmel.htm
My PCB here :
http://antoine.grall.free.fr/docs/CI_progatmel.zip
-
The Pony Prog software :
http://www.lancos.com/prog.html
-
The 40h.hex file given by Monome :
http://monome.org/here/monome40h_firmware.tar.gz
The programmer is very simple to build. The LED is not necessary and will not light if
mounted.
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm
Then just solder some cables between the prommer and the ATMEGA (6 necessary pins) :
GND
VCC
MOSI =>
MISO =>
SCK =>
RESET =>
pin6 of the ATMEGA
pin7 of the ATMEGA
pin8 of the ATMEGA
pin9 of the ATMEGA
You can now plug the programmer to a LPT port and the logic board of the Monome to a
USB port to provide current. !!! Don’t forget the USB, programming the ATMEGA without
feeding it could highly damage it.
Then the Pony Prog software needs some settings :
Step 1 : After you’ve installed Pony Prog, the first thing to do is to choose in the main
window, the device you want to flash : so in the AVR family, the ATMEGA32 :
Step 2 : You can now choose the programmer you use (parallel, AVR ISP I/O), in the
« Setup » => « Interface Setup » menu. You can detect the programmer by clicking on
« Probe »
Step 3 : In the « Setup » menu, you have to calibrate the software by clicking on
« Calibration » (close all the other softwares opened).
Step 4 : You can now open the 40h.hex file.
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm
Step 5 : You have to read and write the fuses of the ATMEGA. They are known in the AVR
family and are used to configure the device. They have to be well written to avoid mistakes
and future programming problems…
Enter the « Command » => « Security & Configuration Bits » menu. Click « Read » to read
and show the actual configuration of the fuses. It is a good way to verify that the device is
recognized. Now check or uncheck the options like that :
NOTA : this configuration can be found on :
http://www.engbedded.com/fusecalc/
You just have to select the device and write the two hexadecimal words EE et 00 in the two
fields at the bottom of the page. These values are given by Monome in the 40h Makefile.
Once you have the correct configuration, you can click « Write ».
Step 6 : The fuses programmed, you just have to send the program in the ATMEGA by
clicking on « Write program flash » in the « Command » menu.
When the ATMEGA is flashed, you can unplug the prommer. The RESET pin of the ATMEGA
must be connected to the VCC for the program to be executed.
The Monome is now alive…
Websites: monome.org - tavernier-c.com - silicium628.fr
Antoine GRALL 2010 | http://antoine.grall.free.fr/monome.htm