Pages: [1]   Go Down
Author Topic: Teaching students what's under the hood (bonnet, if UK)  (Read 962 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd like to be able to see the assembly source code (LDI, ADC...) that gets generated by the Arduino IDE.  I've been trying to do this, quite unsuccessfully, with AtmelStudio.  My goal is to show a group of students how, for example, a digitalWrite  affects the various registers.

Is there a way to read these files from within the Arduino IDE?  If not, has anyone had success using AtmelStudio as a teaching tool for this purpose?

Many thanks, in advance.

Cedric in New Orleans
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not from within the IDE.
I think there are settings or flags you can use with avrdude commands to create/save the assembler commamds, and then use Notepad++ to look at the file.
http://www.ladyada.net/learn/avr/avrdude.html
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

1. Turn on verbose compiling and then click on the "verify" button (LH one) to compile your sketch in verbose mode.

2. Note the name of the .elf file of your sketch (usually the second-last line).

3. In a terminal/command/console window do something like:

avr-objdump -S filename.cpp.elf

(where filename.cpp.elf is from step 2).

I do that so often I made a small "bash" script:

Code:
#!/bin/bash

avr-objdump -S -z $1 > ~/nick.txt

The -z makes it include "zero" bytes (eg. NOP instructions).
Logged

Pages: [1]   Go Up
Jump to: