AVRGCC Programming Using C Development Tools to program

  • Slides: 13
Download presentation
AVR-GCC Programming Using C Development Tools to program your Arduino Microcontrollers. Presented by: Charles

AVR-GCC Programming Using C Development Tools to program your Arduino Microcontrollers. Presented by: Charles Norona November 17 th, 2011 C. Norona, cnorona 1@gmail. com 1

Intro to Win. AVR Set of tools for developing Arduino M/Cs. Includes: Avr-gcc (command

Intro to Win. AVR Set of tools for developing Arduino M/Cs. Includes: Avr-gcc (command line compiler) Avr-libc (compiler library) Avr-as (assembler library) AVRDude (Programming Interface) Avarice (JTAG ICE interface) Avr-gdb (Debugger) Programmer's Notepad (IDE/Code Editor) C. Norona, cnorona 1@gmail. com 2

Getting Win. AVR Download the latest version of Win. AVR at the download page.

Getting Win. AVR Download the latest version of Win. AVR at the download page. Latest version as of Nov. 15, 2011 is 20100110. Run the installer once downloaded. C. Norona, cnorona 1@gmail. com 3

Setting Up the Dev Environment Steps involved: Editing the Makefile. Explanation of the makefile.

Setting Up the Dev Environment Steps involved: Editing the Makefile. Explanation of the makefile. Resources for editing. Setting up and using an IDE. In this case: Programmer's Notepad. Adding custom commands Setting up the project. Running the program. C. Norona, cnorona 1@gmail. com 4

Editing the Make File Explanation of important Makefile instructions. Refer to “Main Tutorial for

Editing the Make File Explanation of important Makefile instructions. Refer to “Main Tutorial for Win. AVR” reference. References for navigating the Makefile: – AVRDude Options (lists of acceptable parameters and commands usage). – Microcontroller Datasheet (tech specs). – AVRDude. conf (configuration file for AVRDude). • Can generally found at: . . /AVRDude. XXXX/bin/avrdude. conf C. Norona, cnorona 1@gmail. com 5

Setting Up and Using an IDE Our IDE needs to be set up with

Setting Up and Using an IDE Our IDE needs to be set up with proper build and make commands. – – – Make All Make Clean Program Device Make Extcoff Make Coff (deprecated) COFF – Common Object File Format. However in the context of the AVR it is referred to as the file format that AVR Studio uses for its debugging. AVR Studio 4. 07 and later also supports an extended COFF format that has a few extra features. The Win. AVR package is able to make both types of COFF files, although you may need to add the COFF extension package on. C. Norona, cnorona 1@gmail. com 6

Setting Up and Using an IDE In Programmer's Notepad the tools customization can be

Setting Up and Using an IDE In Programmer's Notepad the tools customization can be accessed by Tools → Options C. Norona, cnorona 1@gmail. com 7

Setting Up and Using an IDE Make All Command Name: Make All Command: make

Setting Up and Using an IDE Make All Command Name: Make All Command: make Folder: %d Parameters: all Save: Current File C. Norona, cnorona 1@gmail. com 8

Setting Up and Using an IDE Make All Command C. Norona, cnorona 1@gmail. com

Setting Up and Using an IDE Make All Command C. Norona, cnorona 1@gmail. com Capture output: enabled and uses main window. Clear output: optional Output Parsing: Use built-in error parser. 9

Setting Up and Using an IDE Ensure that the rest of the commands are

Setting Up and Using an IDE Ensure that the rest of the commands are implemented. The following are the corresponding settings for each command: C. Norona, cnorona 1@gmail. com 10

#include <avr/io. h> #include <avr/delay. h> void main (void) { unsigned char counter; Running

#include <avr/io. h> #include <avr/delay. h> void main (void) { unsigned char counter; Running a Program Add this code to the new file, test 01. c. //set PORTB for output DRB = 0 x. FF; while (1) { //set PORTB. 2 high PORTB |= 1<<2; //wait (10 * 120000) cycles = wait 1200000 cycles counter = 0; while (counter != 5) { //wait (30000 x 4) cycles = wait 120000 cycles _delay_loop_2(30000); counter++ } //set PORTB. 2 low PORTB &= ~(1<<2); //wait (10 * 120000) cycles = wait 1200000 cycles counter = 0; while (counter != 5) { //wait (30000 x 4) cycles = wait 120000 cycles _delay_loop_2(30000); counter++ } } return 1; } Do not forget to edit the Makefile with appropriate values. Code will have errors for sake of exemplification. C. Norona, cnorona 1@gmail. com 11

Demo Time! C. Norona, cnorona 1@gmail. com 12

Demo Time! C. Norona, cnorona 1@gmail. com 12

References Main page for Win. AVR. http: //winavr. sourceforge. net/helpme. html. Main Tutorial for

References Main page for Win. AVR. http: //winavr. sourceforge. net/helpme. html. Main Tutorial for Win. AVR which this presentation is based on. http: //winavr. sourceforge. net/install_config_Win. AVR. pdf. By C. O'Flynn and E. Weddington AVRDUDE Info. http: //www. nongnu. org/avrdude/user-manual/avrdude_4. html. Win. AVR Download link. http: //sourceforge. net/projects/winavr/files/Win. AVR/20100110/. Arduino Duemilanove Listing. http: //arduino. cc/en/Main/arduino. Board. Duemilanove. Win. AVR GCC Tutorials Source. Contains plenty of tutorials to do various things with your arduino. http: //winavr. scienceprog. com/. C. Norona, cnorona 1@gmail. com 13