User Tools

Site Tools


didattici:avrdude

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
didattici:avrdude [2018/06/29 13:14] profprodidattici:avrdude [2020/06/08 22:20] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +vedere anche [[didattici:simavr]]
 +
 +======AVRDude======
 +
 +http://www.nongnu.org/avrdude/
 +
 +Ogni Arduino ha un proprio microcontrollore e le istruzioni si trovano nel sito Atmel (Instruction set manual).
 +Questi microcontrollori, hanno ridotte capacità di calcolo, ma contengono anche una memoria flash, ed eseguono un solo programma alla volta. Il programma eseguibile viene inserito nella memoria tramite una tecnica detta //in-circuit serial programming//
 +
 +  * Avra è un assembler per la famiglia di microcontrollori Atmel AVR 8-bit (RISC) 
 +  * Avrdude è una interfaccia da linea di comando per upload e download del codice nella memoria di un microcontrollore
 +
 +entrambi sono pacchettizzati su Debian
 +
 +
 +
 +====Avra====
 +
 +http://www.instructables.com/id/Command-Line-Assembly-Language-Programming-for-Ard/
 +
 +Avra dispone di molti file .inc (uno per ogni tipo di microcontrollore), come m329def.inc, purtroppo è assente m328p (atmega328). 
 +
 +Esempio:
 +
 +collegare un LED sul pin PB5 e ad una resistenza di 220 ohm, poi alla terra.
 +
 +<code>
 +;hello.asm
 +;  accende un led sul piedino PB5 (digital out 13)
 +
 +.include "nomefile.inc"
 +
 + ldi r16,0b00100000      ;load immediate
 + out DDRB,r16            ;copia r16 dentro DDRB (la porta 5 diventa di output)
 + out PortB,r16           ;copia r16 dentro PortB (la porta 5 diventa a 5 volt)
 +Avvio:                          ; etichetta
 + rjmp Avvio              ;relative jump (altrimenti il program counter continua a crescere)
 +</code>
 +
 +Comando per produrre hello.hex
 +
 +  avra hello.asm
 +
 +
 +Premere prima il bottone di reset di Arduino e poi eseguire questo comando per caricare il codice eseguibile
 +
 +  avrdude -p m328p -c stk500v1 -b 57600 -P /dev/ttyUSB0 -U flash:w:hello.hex
 +
 +  * bitrate potrebbe essere -b 115200
 +  * porta potrebbe essere -P /dev/ttyACM0
 +
 +Esempio di lettura
 +
 +  avrdude -p m328p -c arduino -b 115200 -P /dev/ttyACM2 -U flash:r:hello.hex:h
 +
 +<code>
 +avrdude: AVR device initialized and ready to accept instructions
 +
 +Reading | ################################################## | 100% 0.00s
 +
 +avrdude: Device signature = 0x1e950f
 +avrdude: reading flash memory:
 +
 +Reading | ################################################## | 100% 4.20s
 +
 +avrdude: writing output file "hello.hex"
 +
 +avrdude: safemode: Fuses OK (E:00, H:00, L:00)
 +
 +avrdude done.  Thank you.
 +
 +</code>
 +
 +========
 +
 +datasheet ATmega328P http://www.microchip.com/wwwproducts/en/ATMEGA328P 
 +
 +| nome  | valore  |
 +| Program Memory Type  | Flash  |
 +| Program Memory Size (KB)  | 32  |
 +| CPU Speed (IPS)  | 20 M  |
 +| SRAM Bytes  | 2048  |
 +| Data EEPROM/HEF (bytes)  | 1024 |