OQArduino Hacking Entry: Platform for Sound Lab Date: Fri Aug 3 15:17:32 EDT 2012 I'm thinking about switching to Arduino to make the sound lab more accessible. Staapl PIC stuff could be a sidekick, possibly in the form of pre-programmed synth chips, but should not be placed in a the critical path. The idea is to teach: - Basic uC stuff on Arduino - Working with a chip API through SPI/I2C. - Some analog electronics Entry: Arduino on debian Date: Fri Aug 3 16:38:41 EDT 2012 apt-get install arduino Get:1 http://ftp.be.debian.org/debian/ wheezy/main arduino-core all 1:1.0.1+dfsg-4 [717 kB] Get:2 http://ftp.be.debian.org/debian/ wheezy/main arduino all 1:1.0.1+dfsg-4 [1,123 kB] Start it once and let it add your user to the dialout group. After that, you need to log in again for the changes to take effect. Edit the configuration file .arduino/preferences.txt and change this line: serial.port=/dev/ttyACM0 Entry: Makefile Date: Sat Aug 4 16:03:28 EDT 2012 Next step: I want to know how it works. Tried this[1] but it doesn't work with 1.0 arduino version. Switching to [2] + made some modifications. [1] http://www.arduino.cc/playground/Learning/CommandLine [2] http://www.kerrywong.com/2011/12/17/makefile-for-arduino-1-0/ Entry: avrdude on the Arduino UNO Date: Sat Aug 4 20:02:54 EDT 2012 This worked for me, copied from [1]. avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:main.hex [1] http://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/ Entry: Resetting using DTR Date: Sat Aug 4 20:04:45 EDT 2012 stty -F $(AVRDUDE_PORT) hupcl perl -MDevice::SerialPort -e 'Device::SerialPort->new("$(AVRDUDE_PORT)")->pulse_dtr_on(1000)'; Entry: Next Date: Sun Aug 5 18:51:28 EDT 2012 So.. I feel a bit comfortable with what's going on after tinkering with the Makefile. Next step is probably to read the ATmega328P datasheet. Entry: ATmega328P Date: Sun Aug 5 18:59:03 EDT 2012 - 32 8-bit registers (memory mapped to 00-1F) - 3 16-bit index registers (using 6 of the 32 8-bit registers) - call stack is in SRAM, SP in I/O space - 234 byte I/O space (memory mapped to 20-5F + 60-FF) ( For a procedural forth the 3 indirect registers would be a/b pointers and datastack. There is probably enough register space to make it 16 bit. ) Entry: ATmega328P (Arduino UNO) + avrdude Date: Mon Aug 13 21:02:40 EDT 2012 Trick is that my UNO has a m328-pu and not a m328p. Forcing it works: sudo avrdude -c usbtiny -p m328p -F -U flash:r:test.bin:r [1] http://arduino.cc/forum/index.php?topic=58670.0 Entry: AVR I/O pins Date: Fri Aug 17 14:50:42 EDT 2012 AVR I/O pins config is a bit different than PIC's. From ATmega328P data sheet, table 13-1: PUD DDxn PORTxn (in MCUCR) I/O Pull-up Comment 0 0 X Input No Tri-state (Hi-Z) 0 1 0 Input Yes Pxn will source current if ext. pulled low. 0 1 1 Input No Tri-state (Hi-Z) 1 0 X Output No Output Low (Sink) 1 1 X Output No Output High (Source) Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit.