====== mC wökrshop ====== ---- datatemplateentry project ---- template : :sys:tpl:project description : Wökrshop zur mC prgrammierung coordinators : [[:users:skruppy:]] confidants : [[:users:wanda:]], [[:users:sushi:]], Fred state_tags : held, to be continued type_tags : software, elektro, C, event, workshop ---- Wer macht mit * sushi * loon (Hat wer nen Leihduino???) * Skruppy (Hat wer nen Leihduino???) * wanda (...Boarduino + ein eHaserl...bringe beides mit) * fred Themen * Tool chain * I/O * Timer * Interrups * HowTo RTFM Vorbereitung * Alles was AVR (8-Bit ATEML Microcontroller) mäsiges, wass schnell programmierbar ist (kein [[http://en.wikipedia.org/wiki/Bit_banging|Bit-Banging]] oder so). Also E-Haserl, FooDoinos, Development boards, ... * Datenblatt von [[http://www.atmel.com/products/avr/default.asp?source=cms&category_id=163&family_id=607&source=global_nav|ATMEL]] über euren Chip herunterladen. Es sind i.d.R. PDFs mit mehr als 500 Seiten. * Schaltpläne Pinouts suchen und mitnehmen, wenn nicht schon sauber aufgedruckt (ihr müsst halt wissen "Pin Nummer x geht auf diesen Kontakt"). * Programmierkabel falls nötig. * Breadboard, LED, Schalter, Jumper wires oder so, sinvoll für I/O. ===== Materialien ===== Das hier kann während des wörkshops mit Spickzetteln, Code sippets, Links, ... gefüllt werden. ==== Hilfe ==== * http://www.nongnu.org/avr-libc/user-manual/modules.html * http://www.heise.de/ct/artikel/Shake-rattle-n-roll-292164.html * http://www.ladyada.net/learn/arduino/ ==== Löten iss sooo einfach ==== "Löten ist einfach! und so wirds gemacht" (Comic): {{:elektro:fullsoldercomic_de.pdf|}} ==== Boarduino ==== **Infos**: http://ladyada.net/make/boarduino/ \\ **Plan als .png**: http://ladyada.net/images/boarduino/boarduinosch.png\\ \\ **Chipinfos**: \\ unter: http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf\\ * ATmega328P/ 16.00 MHz * Flash (Kbytes): 32 * Pin Count: 32 * Max. Operating Frequency: 20 * CPU: 8-bit AVR ==== ehaserl ==== [[projects:ehaserl]] ==== AVR-Videos ==== evtl. hilfreich (noch nicht geguckt - also testen :-) ) * 25C3: Music with Microcontrollers: http://events.ccc.de/congress/2008/Fahrplan/events/2843.en.html * 26C3: Advanced Microcontroller Programming: http://events.ccc.de/congress/2009/Fahrplan/events/3672.en.html ===== AVR ===== sudo apt-get install gcc-avr avrdude avr-libc binutils-avr * **avrdude** \\ Schreibt ("flasht") die Firmware in den Flash speicher des mC. Für arduinos ist die flash methode "arduino" * **avr-libc** \\ Wer nicht auf hard core assembler steht, hat damt ein Grundgerüst um z.B. auf Ports per Namen zu zu greifen!!!11elf ([[http://www.nongnu.org/avr-libc/user-manual/modules.html|Doku]]) * **gcc-avr** \\ Der compiler (dieser macht keine lecker sandwiches) * **binutils-avr** \\ Tools um infos über die compilate etc. zu bekommen und zu konvertieren und lauter so klein kram. Das sind alle Pakete, die Fisch braucht. ===== Makefile für: ATmega1280 ===== Makefile kopier quellen * https://github.com/Skrupellos/Capacitive-touch-sensor/blob/master/Makefile [sic!] * http://www.mikrocontroller.net/articles/AVR-GCC-Tutorial/Exkurs_Makefiles * http://www.mikrocontroller.net/articles/Beispiel_Makefile \\ \\ Vorsicht: \\ Für den **ATmega328P (Boarduino)** MCU wie follgt ändern: MCU = atmega32 avrdude muss so konfuguriert werden, dass er für arduinos "-b 57600 -p atmega32 -c arduino" bzw. "-b 57600 -p -c arduino" als aufrufparameter bekommt. Dazu einfach mal nach AVRDUDE_* oder ähnlichem in den Makefiles suchen ... Makefiles sind einaml zu recht gefrikelt und dann immer wieder kopiert gut zu gebrauchen xD. ===== Code aus dem Wörkshop ===== #include // this contains all the IO port definitions #include // definitions for interrupts #include // definitions for power-down modes #include #include #include int main() { // 1111 1111 DDRA = 255; // Data direction register (1 = output / 0 = input) DDRA = 0b11111111; DDRA = 0xFF; // alles output DDRA = _BV(PA0) | _BV(PA1) | _BV(PA2) | _BV(PA3) | _BV(PA4) | _BV(PA5) | _BV(PA6) | _BV(PA7); DDRH = 0b00000000; // alles input PORTH = 0b00000100; // Pull-up an while(true) { // 0000 0000 /* PORTA = 0b00000001; // Erstes led an // Pegel definieren (1 = high / 0 low) //PORTA = _BV(PA6) | _BV(PA4); // Pegel definieren (1 = high / 0 low) _delay_ms(1000); PORTA = PORTA | 0b00000010; // zweites led an _delay_ms(1000); PORTA = PORTA & ~0b00000001; // erstes LED aus _delay_ms(1000); PORTA = PORTA & 0b11111101; // zweites LED aus _delay_ms(1000); */ if(PINH & 0b00000100){ PORTA = PORTA & ~0b00000001; }else{ PORTA = PORTA | 0b00000001; } } // 0000 0001 = 1 = 1 << 0 = _BV(0) = _BV(PA0) // 0000 0100 = 4 = 1 << 2 = _BV(2) = _BV(PA2) // ========================================== // 0000 0101 = 1 | 4 = 5 // BINÄÄÄRES ORDER // 0001 0101 = 21 // 1000 0110 = 134 // =============== // 1001 0111 = 155 // }