- Ubuntu 14.04 LTS
- Qt Creator 3.0.1
- avr-g++ (gcc version 4.8.2 (GCC))
- avrdude 6.0.1
Création du projet
Créer un dossier pour le projet:
mkdir path/to/myproject
Se placer dans ce dossier:
cd path/to/myproject
Créer cinq fichiers vierges:
touch myproject.config myproject.creator myproject.files myproject.includes main.cpp
Ajouter le mot-clé [General] dans le fichier myproject.creator:
echo [General] > myproject.creator
Ajouter le nom du fichier source main.cpp dans le fichier myproject.files:
echo main.cpp > myproject.files
Démarrer Qt Creator et ouvrir le fichier myproject.creator. Vous pouvez aussi ouvrir le fichier avec un clic droit ou avec la commande suivante:
qtcreator myproject.creator
Lorsque Qt Creator est démarré, le project doit être visible. Editer le fichier main.cpp, voici un exemple de code très simple pour commencer:
/*
* This simple program shows how to start with Qt-Creator, avr-g++ and avrdude
*
*
* Fuses configuration (Fuses OK (H:FF, E:DF, L:EE):
* Extended : 0xDF
* High : 0xFF
* Low : 0xEE
*
*
* To compile the project :
* avr-g++ -mmcu=atmega32m1 -Os main.cpp -o output.elf
*
* To upload the file :
* avrdude -c avrispmkII -p m32m1 -P usb -U flash:w:output.elf
*
* To update the fuses :
* avrdude -c avrispmkII -p m32m1 -P usb -U flash:w:output.elf -Ulfuse:w:0xeEE:m -Uhfuse:w:0xFF:m -Uefuse:w:0xDF:m
*
* Qt Creator project configuration:
*
* Build steps (Custom Process Step)
* Command : avr-g++
* Arguments : -mmcu=atmega32m1 -Os main.cpp -o output.elf
* Working directory : %{buildDir}
*
* Clean steps(Custom Process Step)
* Command : avrdude
* Arguments : -c avrispmkII -p m32m1 -P usb -U flash:w:output.elf
* Working directory : %{buildDir}
*
* Run (Custom
*
*/
// 8MHz oscillator
#define F_CPU 8000000UL
#include
#include
int main()
{
// Set bit 7 of PORTC as output
DDRC=0x80;
while (1)
{
// Invert the bit 7 of PORTC
PORTC = PORTC ^ 0x80;
// Wait 500ms (the leb connectod to the bit 7 of PORTC will blink at 1Hz)
_delay_ms(1000);
}
}
Configurer le projet
Dans l’onglet Project (sur la gauche) configurer Qt Creator en vous inspirant des captures d’écran suivantes:
Pour programmer la cible, deux options sont possibles (Deployment ou Run). J’ai utilisé Deployment car le résultat de la programation est directement intégrée à l’IDE Qt Creator (la barre devient rouge en cas de problème). Un exectuable doit être configuré, la commande echo sert ici de commande vide.
Notez également que cet exemple utilise un atmega32m1 qui n’est pas supporté nativement par cette version d’avrdude (remplacer par exemple m32m1 par m328p si vous souhaitez utiliser un atmega328p).