<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="it">
	<id>https://www.raspibo.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pat1</id>
	<title>raspibo - Contributi utente [it]</title>
	<link rel="self" type="application/atom+xml" href="https://www.raspibo.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pat1"/>
	<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php/Speciale:Contributi/Pat1"/>
	<updated>2026-06-15T03:53:01Z</updated>
	<subtitle>Contributi utente</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Prossimi_appuntamenti&amp;diff=7378</id>
		<title>Prossimi appuntamenti</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Prossimi_appuntamenti&amp;diff=7378"/>
		<updated>2023-02-13T16:36:14Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Ricominciamo! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- === '''12 giugno 2018, ore 20:30''' === --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Io la data per gli appuntamenti fissi la eliminerei, tanto e` scritto due righe piu` giu`, altrimenti si deve sempre riscrivere, --~~~~ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Anche se è sempre da riscrivere penso sia un segno visibile. Magari scriviamo uno script che l'aggiorni.... (renzo) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- '''Chiusura temporanea del Centro Sociale Croce di Casalecchio di Reno.'''&lt;br /&gt;
&lt;br /&gt;
Come comunicato dalla direzione  vi segnaliamo che da Domenica 23.02.2020 fino alle ore 24,00 di Domenica 01.03.2020, il Centro Sociale Croce di Casalecchio di Reno sarà chiuso e saranno annullati a data da destinarsi tutti gli eventi programmati. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ''' Ricominciamo? '''&lt;br /&gt;
&lt;br /&gt;
Il 27 ottobre 2012 nasce l'idea di RaspiBO durante le presentazioni del Linux Day. RaspiBO quindi compie 10 anni.&lt;br /&gt;
&lt;br /&gt;
Dopo la sospensione delle attività a causa della pandemia stiamo pensando di riprendere i nostri incontri.&lt;br /&gt;
Se siete interessati partecipate alle discussioni sulla mailing list agora. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Abbiamo ricominciato! ===&lt;br /&gt;
&lt;br /&gt;
Il nuovo incontro zero è fissato per martedì 14 febbraio 2022 alle ore 21:00 al Centro Croce Via Canonica 18 a Casalecchio di Reno, Bologna.&lt;br /&gt;
&lt;br /&gt;
A presto&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Prossimi_appuntamenti&amp;diff=7377</id>
		<title>Prossimi appuntamenti</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Prossimi_appuntamenti&amp;diff=7377"/>
		<updated>2023-02-13T16:35:50Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Ricominciamo! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- === '''12 giugno 2018, ore 20:30''' === --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Io la data per gli appuntamenti fissi la eliminerei, tanto e` scritto due righe piu` giu`, altrimenti si deve sempre riscrivere, --~~~~ --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Anche se è sempre da riscrivere penso sia un segno visibile. Magari scriviamo uno script che l'aggiorni.... (renzo) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- '''Chiusura temporanea del Centro Sociale Croce di Casalecchio di Reno.'''&lt;br /&gt;
&lt;br /&gt;
Come comunicato dalla direzione  vi segnaliamo che da Domenica 23.02.2020 fino alle ore 24,00 di Domenica 01.03.2020, il Centro Sociale Croce di Casalecchio di Reno sarà chiuso e saranno annullati a data da destinarsi tutti gli eventi programmati. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ''' Ricominciamo? '''&lt;br /&gt;
&lt;br /&gt;
Il 27 ottobre 2012 nasce l'idea di RaspiBO durante le presentazioni del Linux Day. RaspiBO quindi compie 10 anni.&lt;br /&gt;
&lt;br /&gt;
Dopo la sospensione delle attività a causa della pandemia stiamo pensando di riprendere i nostri incontri.&lt;br /&gt;
Se siete interessati partecipate alle discussioni sulla mailing list agora. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ricominciamo! ===&lt;br /&gt;
&lt;br /&gt;
Il nuovo incontro zero è fissato per martedì 14 febbraio 2022 alle ore 21:00 al Centro Croce Via Canonica 18 a Casalecchio di Reno, Bologna.&lt;br /&gt;
&lt;br /&gt;
A presto&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7360</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7360"/>
		<updated>2021-12-14T18:50:16Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
o anche questo che calcola anche i lock bits:&lt;br /&gt;
https://eleccelerator.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
se invece usi digitecoboot di 4k di dimensione:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x18:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  --reset-srst :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino con il suo bootloader ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0xCF:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using digitecoboot the commands are:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0xCF:m&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7359</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7359"/>
		<updated>2021-12-14T18:45:06Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino con il suo bootloader */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
se invece usi digitecoboot di 4k di dimensione:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x18:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  --reset-srst :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino con il suo bootloader ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0xCF:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using digitecoboot the commands are:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0xCF:m&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7358</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7358"/>
		<updated>2021-12-14T18:12:15Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
se invece usi digitecoboot di 4k di dimensione:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x18:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  --reset-srst :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino con il suo bootloader ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using digitecoboot the commands are:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7357</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7357"/>
		<updated>2021-12-14T17:39:44Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
se invece usi digitecoboot di 4k di dimensione:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x18:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  --reset-srst :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7356</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7356"/>
		<updated>2021-12-14T10:51:12Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Sessione di debug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  --reset-srst :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7355</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7355"/>
		<updated>2021-12-14T10:49:26Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xDE&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0x1E&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=File:Jtag_isp.png&amp;diff=7354</id>
		<title>File:Jtag isp.png</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=File:Jtag_isp.png&amp;diff=7354"/>
		<updated>2021-12-11T13:20:32Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=File:Jtag_isp_schema.png&amp;diff=7353</id>
		<title>File:Jtag isp schema.png</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=File:Jtag_isp_schema.png&amp;diff=7353"/>
		<updated>2021-12-11T13:20:12Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7352</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7352"/>
		<updated>2021-12-11T13:18:54Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Collegamenti */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp_schema.png]]&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
[[File:jtag_isp.png]]&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7351</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7351"/>
		<updated>2021-12-11T13:07:29Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xFF:m -U hfuse:w:0x1E:m -U efuse:w:0xFD:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7350</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7350"/>
		<updated>2021-12-11T12:57:26Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x3f:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x0f:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0xFF:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7349</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7349"/>
		<updated>2021-12-11T12:53:31Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x3f:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x0f:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0x3F:m -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7348</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7348"/>
		<updated>2021-12-11T12:39:00Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x3f:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x0f:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xDE:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7347</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7347"/>
		<updated>2021-12-11T12:35:52Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x3f:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0x0f:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7346</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7346"/>
		<updated>2021-12-11T12:00:20Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Come far tornare l'arduino come un vero arduino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -V -U flash:w:optiboot_atmega1280.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7345</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7345"/>
		<updated>2021-12-11T11:44:38Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Sessione di debug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con le opzioni di debug determinati dall'opzione&lt;br /&gt;
 build_type = debug&lt;br /&gt;
&lt;br /&gt;
in platformio.ini&lt;br /&gt;
&lt;br /&gt;
 pio run -t upload&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
&lt;br /&gt;
 ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''oppure ddd'''&lt;br /&gt;
 ddd --debugger ~/.platformio/packages/toolchain-atmelavr/bin/avr-gdb .pio/build/644pa16m/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7344</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7344"/>
		<updated>2021-12-11T11:39:18Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Fuse Setting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p  m1284p -c dragon_isp -P usb -U flash:w:firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
oppure:&lt;br /&gt;
 avrdude  -p  m644p  -c dragon_isp -P usb -U flash:w:firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7343</id>
		<title>Gruppo Meteo/HowTo/DebugAVR</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/HowTo/DebugAVR&amp;diff=7343"/>
		<updated>2021-12-10T16:41:20Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Come debuggare con AVR Dragon su arduino'''&lt;br /&gt;
&lt;br /&gt;
WARNING&lt;br /&gt;
&lt;br /&gt;
It is possible, using the tools discussed here to either ‘brick’ your processor or physically destroy it.  This also includes your AVR Dragon.  Make sure you double and triple check all connections BEFORE you turn on any power and make sure you disconnect the power BEFORE making any wiring changes.&lt;br /&gt;
&lt;br /&gt;
I can not be held responsible for your errors in skills or judgement.&lt;br /&gt;
&lt;br /&gt;
= Microduino e platformio =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* Microduino core/core+&lt;br /&gt;
* AVR Dragon (sostituito da https://www.mouser.it/new/microchip/microchip-atmel-ice-kit/ ?)&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
https://atmega32-avr.com/wp-content/uploads/2012/11/AVR_Dragon_Manual_User_Guide.pdf&lt;br /&gt;
https://ww1.microchip.com/downloads/en/devicedoc/atmel-42723-avr-dragon_userguide.pdf&lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* platformio&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
oppure utilizzare il default per platformio:&lt;br /&gt;
&lt;br /&gt;
 https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|MicroduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v/3.3v 	        &lt;br /&gt;
| +5v/+3.3v	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|D19 (no upin27, in extension for core+) 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D18 (no upin27, in extension for core+)&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|D17 (no upin27, in extension for core+)&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|D16 (no upin27, in extension for core+)&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Microduino core+ and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine D16, D17, D18 or D19 on the Microduino, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p m1284p  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p  m1284p -c dragon_isp -P usb -U flash:w:firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
oppure:&lt;br /&gt;
 avrdude  -p  m644p  -c dragon_isp -P usb -U flash:w:firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;br /&gt;
&lt;br /&gt;
= Arduino mega2560 =&lt;br /&gt;
&lt;br /&gt;
== materiali necessari ==&lt;br /&gt;
hardware:&lt;br /&gt;
* arduino mega2560&lt;br /&gt;
* AVR Dragon&lt;br /&gt;
* cavi ...&lt;br /&gt;
* un pc &lt;br /&gt;
&lt;br /&gt;
software:&lt;br /&gt;
* un sistema operativo serio (Linux)&lt;br /&gt;
* toolchain gcc per avr&lt;br /&gt;
* avrdude&lt;br /&gt;
* avarice&lt;br /&gt;
* gdb&lt;br /&gt;
* ddd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operazioni sistemistiche preliminari ==&lt;br /&gt;
&lt;br /&gt;
Queste operazioni sono necessarie per rendere disponibile AVR Dragon agli utenti abilitati (quelli del gruppo '''dialout'''); altrimenti sarà solo root a poter agire.&lt;br /&gt;
&lt;br /&gt;
Istruzioni valide per Fedora, per altro non so.&lt;br /&gt;
&lt;br /&gt;
Da utente root:&lt;br /&gt;
&lt;br /&gt;
editare il file /etc/udev/rules.d/50-avrdragon.rules e inserire:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;03eb&amp;quot;, ATTR{idProduct}==&amp;quot;2107&amp;quot;, GROUP=&amp;quot;dialout&amp;quot;, MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
&lt;br /&gt;
eseguire:&lt;br /&gt;
&lt;br /&gt;
 service systemd-udevd restart&lt;br /&gt;
&lt;br /&gt;
== Collegamenti ==&lt;br /&gt;
'''ISP:'''&lt;br /&gt;
In System Programming using SPI is well suited for programming devices soldered onto external target boards. This section explains how to connect the Atmel AVR Dragon to SPI program an external target. The SPI lines are equipped with level converters that automatically will level shift the AVR Dragon signals to the target board voltage.&lt;br /&gt;
&lt;br /&gt;
It is recommended that a 6-pin header connector with 2.54mm (100 MIL) spacing is placed on the target board to allow easy access to the SPI programming interface. The following pinout should be used.&lt;br /&gt;
&lt;br /&gt;
6pin Header Connector with 2.54mm (100 MIL) spacing&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/images/ISPHEADER.jpg&lt;br /&gt;
&lt;br /&gt;
Questo la disposizione dei pin sulla board Arduino &lt;br /&gt;
http://arduino-info.wikispaces.com/file/view/Mega2560_R3_Label-small-v2%20%282%29.png/471429496/800x526/Mega2560_R3_Label-small-v2%20%282%29.png&lt;br /&gt;
&lt;br /&gt;
il collegamento ISP una volta capito è facile: l'ordine è il medesimo, basta trovare il pin 1 del connettore.&lt;br /&gt;
&lt;br /&gt;
link:&lt;br /&gt;
http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html&lt;br /&gt;
http://arduino-info.wikispaces.com/MegaQuickRef&lt;br /&gt;
&lt;br /&gt;
'''Jtag:'''&lt;br /&gt;
&lt;br /&gt;
http://support.atmel.no/knowledgebase/avrstudiohelp/mergedProjects/AVRDragon/JTAG_schematic_target.JPG&lt;br /&gt;
&lt;br /&gt;
There are only 7 connections needed and these are as follows:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|arduinoPin 	&lt;br /&gt;
|Signal &lt;br /&gt;
|Dragon Jtag              &lt;br /&gt;
|I/O 	   &lt;br /&gt;
|Description&lt;br /&gt;
|-&lt;br /&gt;
|5v 	        &lt;br /&gt;
| +5v 	&lt;br /&gt;
|4                        &lt;br /&gt;
|Output  &lt;br /&gt;
|5v Supply from Arduino&lt;br /&gt;
|-&lt;br /&gt;
|GND 	        &lt;br /&gt;
|GND 	&lt;br /&gt;
|2 or 10 (either will do) &lt;br /&gt;
| - 	   &lt;br /&gt;
|Ground reference&lt;br /&gt;
|-&lt;br /&gt;
|analog in 4 	&lt;br /&gt;
|TCK 	&lt;br /&gt;
|1                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Clock, clock signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 5 	&lt;br /&gt;
|TMS 	&lt;br /&gt;
|5                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Mode Select, mode select signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|analog in 6 	&lt;br /&gt;
|TDO 	&lt;br /&gt;
|3                        &lt;br /&gt;
|Output  &lt;br /&gt;
|Test Data Output, data signal from target JTAG port to AVR Dragon&lt;br /&gt;
|-&lt;br /&gt;
|analog in 7 	&lt;br /&gt;
|TDI 	&lt;br /&gt;
|9                        &lt;br /&gt;
|Input   &lt;br /&gt;
|Test Data Input, data signal from AVR Dragon to target JTAG port&lt;br /&gt;
|-&lt;br /&gt;
|reset          &lt;br /&gt;
|RST    &lt;br /&gt;
|6                        &lt;br /&gt;
|        &lt;br /&gt;
|Reset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: These pin numbers refer to the shield pin numbers of the Arduino Mega2560 and not to the pins on the processor.&lt;br /&gt;
Note: Although the +5v are joined, you will still need to provide power to your Mega board by any of the normal methods.  The sole purpose of the +5v connection is to correctly configure the level shifters/converts used by the Dragon to process signals between the boards.  If you are using a 3.3v Dragon, then it is important that you connect the +5v signal to the +3.3v signal instead.  Otherwise there is a pretty good chance you will destroy your Mega in a few seconds.  This signal can not power the Mega from the Dragon!&lt;br /&gt;
&lt;br /&gt;
Note: Power up your Mega board before the Dragon.&lt;br /&gt;
&lt;br /&gt;
Note: Make sure there are no other connections to pine 4, 5, 6 or 7 on the Mega, other than those to the Dragon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fuse Setting ==&lt;br /&gt;
&lt;br /&gt;
http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/&lt;br /&gt;
&lt;br /&gt;
'''default Arduino Mega 2560 '''&lt;br /&gt;
&lt;br /&gt;
* Low Fuse 	0xFF&lt;br /&gt;
* High Fuse 	0xD8&lt;br /&gt;
* Extended Fuse 0xFD&lt;br /&gt;
&lt;br /&gt;
you need to enable the OCDEN and JTAGEN fuses&lt;br /&gt;
&lt;br /&gt;
Per il calcolo si può utilizzare:&lt;br /&gt;
http://www.engbedded.com/fusecalc/&lt;br /&gt;
&lt;br /&gt;
da cui si ottiene:&lt;br /&gt;
-U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
quindi:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
Quando avari finito tutto reimpostare i valori di dafault:&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -U lfuse:w:0xff:m -U hfuse:w:0xf8:m -U efuse:w:0xfd:m &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sessione di debug ==&lt;br /&gt;
&lt;br /&gt;
Dopo aver compilato (io uso ino) con l'opzione -g e preferibilmente con -g2 -O0 caricare il programma usanto l'interfaccia jstag e il Dragon:&lt;br /&gt;
&lt;br /&gt;
 avrdude  -p atmega2560 -c dragon_isp -P usb -U flash:w:.build/mega2560/firmware.hex:i&lt;br /&gt;
&lt;br /&gt;
eseguire avarice che rimane in attesa di connessione da parte di gdb:&lt;br /&gt;
&lt;br /&gt;
  avarice --dragon  :4242&lt;br /&gt;
&lt;br /&gt;
poi lanciare il debugger:&lt;br /&gt;
 avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
'''attenzione !! ddd non funziona e chissà perchè'''&lt;br /&gt;
 ddd --debugger avr-gdb .build/mega2560/firmware.elf&lt;br /&gt;
&lt;br /&gt;
At the (gdb) prompt, tell GDB to connect to AVaRICE:&lt;br /&gt;
&lt;br /&gt;
 (gdb) target remote localhost:4242&lt;br /&gt;
&lt;br /&gt;
This will stop the program running on the APM and tell you where it stopped:&lt;br /&gt;
&lt;br /&gt;
 Remote debugging using localhost:4242&lt;br /&gt;
 0x00002992 in AP_GPS_NMEA::read (this=0x8007aa)&lt;br /&gt;
 at /Volumes/Data/Users/msmith/work/Mike/ArduPilot/Sketchbook/libraries/AP_GPS/AP_GPS_NMEA.cpp:72&lt;br /&gt;
 72		numc = _port-&amp;gt;&lt;br /&gt;
 available();&lt;br /&gt;
 (gdb)&lt;br /&gt;
&lt;br /&gt;
Use the ‘continue’ command to start the program running again, and hit control-C to stop it once more.&lt;br /&gt;
&lt;br /&gt;
== Come far tornare l'arduino come un vero arduino ==&lt;br /&gt;
&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -e -u -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560  -V -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex&lt;br /&gt;
 avrdude -c dragon_isp -P usb -p atmega2560 -U lock:w:0x0F:m&lt;br /&gt;
&lt;br /&gt;
The first command unlocks the bootloader section and sets the fuses.&lt;br /&gt;
The second writes the bootloader to the flash memory.&lt;br /&gt;
And the third locks the bootloader section again.&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7323</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7323"/>
		<updated>2020-11-02T23:36:32Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Alternative =&lt;br /&gt;
== estendere un bus I2C ==&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
== rs-485 vs can bus ==&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
Each node requires a:&lt;br /&gt;
&lt;br /&gt;
* Central processing unit, microprocessor, or host processor&lt;br /&gt;
* CAN controller; often an integral part of the microcontroller&lt;br /&gt;
* Transceiver Defined by ISO 11898-2/3 Medium Access Unit [MAU] standards&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* https://en.wikipedia.org/wiki/CAN_bus&lt;br /&gt;
&lt;br /&gt;
== corsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= Protocols =&lt;br /&gt;
*    CANopen - manufacturing process control&lt;br /&gt;
*    SAE J1939 - off road truck and bus&lt;br /&gt;
*    UAVCAN intravehicular communication in aerospace and robotic applications&lt;br /&gt;
*    ISO 11783 - agricultural&lt;br /&gt;
*    OBDII - automotive diagnostics&lt;br /&gt;
*    NMEA 2000 - GPS and navigation&lt;br /&gt;
&lt;br /&gt;
== CanOpen ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
== SAE_J1939 ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
== UAVCAN ==&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
=== specifiche ===&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
=== Applicazioni ===&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
=== libreria per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== pyuavcan ===&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN libreria c++ semplificata per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7322</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7322"/>
		<updated>2020-11-02T16:07:32Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Alternative =&lt;br /&gt;
== estendere un bus I2C ==&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
== rs-485 vs can bus ==&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
Each node requires a:&lt;br /&gt;
&lt;br /&gt;
* Central processing unit, microprocessor, or host processor&lt;br /&gt;
* CAN controller; often an integral part of the microcontroller&lt;br /&gt;
* Transceiver Defined by ISO 11898-2/3 Medium Access Unit [MAU] standards&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== corsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= Protocols =&lt;br /&gt;
*    CANopen - manufacturing process control&lt;br /&gt;
*    SAE J1939 - off road truck and bus&lt;br /&gt;
*    UAVCAN intravehicular communication in aerospace and robotic applications&lt;br /&gt;
*    ISO 11783 - agricultural&lt;br /&gt;
*    OBDII - automotive diagnostics&lt;br /&gt;
*    NMEA 2000 - GPS and navigation&lt;br /&gt;
&lt;br /&gt;
== CanOpen ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
== SAE_J1939 ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
== UAVCAN ==&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
=== specifiche ===&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
=== Applicazioni ===&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
=== libreria per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== pyuavcan ===&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN libreria c++ semplificata per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7321</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7321"/>
		<updated>2020-11-02T16:06:39Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
Each node requires a:&lt;br /&gt;
&lt;br /&gt;
* Central processing unit, microprocessor, or host processor&lt;br /&gt;
* CAN controller; often an integral part of the microcontroller&lt;br /&gt;
* Transceiver Defined by ISO 11898-2/3 Medium Access Unit [MAU] standards&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== corsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= Protocols =&lt;br /&gt;
*    CANopen - manufacturing process control&lt;br /&gt;
*    SAE J1939 - off road truck and bus&lt;br /&gt;
*    UAVCAN intravehicular communication in aerospace and robotic applications&lt;br /&gt;
*    ISO 11783 - agricultural&lt;br /&gt;
*    OBDII - automotive diagnostics&lt;br /&gt;
*    NMEA 2000 - GPS and navigation&lt;br /&gt;
&lt;br /&gt;
== CanOpen ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
== SAE_J1939 ==&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
== UAVCAN ==&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
=== specifiche ===&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
=== Applicazioni ===&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
=== libreria per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== pyuavcan ===&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN libreria c++ semplificata per arduino ===&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
=== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ===&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7320</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7320"/>
		<updated>2020-11-02T16:02:32Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Can Bus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
Each node requires a:&lt;br /&gt;
&lt;br /&gt;
* Central processing unit, microprocessor, or host processor&lt;br /&gt;
* CAN controller; often an integral part of the microcontroller&lt;br /&gt;
* Transceiver Defined by ISO 11898-2/3 Medium Access Unit [MAU] standards&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== corsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7319</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7319"/>
		<updated>2020-11-02T11:07:24Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* cosrsi */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== corsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7318</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7318"/>
		<updated>2020-10-29T15:12:14Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== cosrsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
* http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== OpenBLT Bootloader ===&lt;br /&gt;
OpenBLT is an open source bootloader for STM32, XMC, HCS12 and other microcontroller targets.&lt;br /&gt;
&lt;br /&gt;
By default, it supports communication interfaces such as: RS232, CAN, USB, TCP/IP and it ships with the easy-to-use MicroBoot PC tool for initiating and monitoring the firmware update. Performing firmware updates directly from an SD-card is also supported.&lt;br /&gt;
&lt;br /&gt;
* https://github.com/feaser/openblt&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7317</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7317"/>
		<updated>2020-10-29T14:45:37Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== cosrsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
=== SLCAN ===&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== Can bus in Linux ===&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
=== Can bus python ===&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== busmaster per windows ===&lt;br /&gt;
http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== librerie per STM32 === &lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7316</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7316"/>
		<updated>2020-10-29T13:04:53Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== cosrsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
== busmaster per windows ==&lt;br /&gt;
http://rbei-etas.github.io/busmaster/&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7315</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7315"/>
		<updated>2020-10-29T13:03:04Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Can bus in Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== cosrsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
&lt;br /&gt;
SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel. Formerly known as Low Level CAN Framework (LLCF).&lt;br /&gt;
&lt;br /&gt;
The socketcan package is an implementation of CAN protocols (Controller Area Network) for Linux. While there have been other CAN implementations for Linux based on character devices, SocketCAN uses the Berkeley socket API, the Linux network stack, and implements the CAN device drivers as network interfaces. The CAN socket API has been designed as similar as possible to the TCP/IP protocols to allow programmers, familiar with network programming, to easily learn how to use CAN sockets. More info on SocketCAN can be &lt;br /&gt;
&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7314</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7314"/>
		<updated>2020-10-29T11:15:46Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* Can Bus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
== cosrsi ==&lt;br /&gt;
* https://www.kvaser.com/course/can-protocol-tutorial/    !!!!!&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== CAN message filtering ==&lt;br /&gt;
Use of 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
* https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
* https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
* http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
&lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
* set filter to 0&lt;br /&gt;
* set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
* set filter to 00001567&lt;br /&gt;
* set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
* set filter to 00001560&lt;br /&gt;
* set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7313</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7313"/>
		<updated>2020-10-29T11:05:00Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* UAVCAN */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* riassunto: https://www.kvaser.com/uavcan/&lt;br /&gt;
&lt;br /&gt;
== specifiche ==&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== Applicazioni ==&lt;br /&gt;
* Px4 https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
* https://ardupilot.org/dev/docs/can-bus.html&lt;br /&gt;
* https://electric-skateboard.builders/t/all-new-2019-vesc-tool-release/83619&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7312</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7312"/>
		<updated>2020-10-29T07:50:51Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* UAVCAN */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
* https://uavcan.org/&lt;br /&gt;
* https://forum.uavcan.org/t/the-uavcan-guide/778&lt;br /&gt;
* https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
* https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
* https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7311</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7311"/>
		<updated>2020-10-29T07:47:16Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
&lt;br /&gt;
=== CAN Transceiver MCP2551 ===&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7310</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7310"/>
		<updated>2020-10-29T07:31:07Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== can priority inversion ==&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== CAN SPI mcp2515 ===&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
== software ==&lt;br /&gt;
=== exocan ===&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32CAN ===&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
== CANdevStudio ==&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7309</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7309"/>
		<updated>2020-10-29T07:24:33Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
=== CANdevStudio ===&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
=== can priority inversion ===&lt;br /&gt;
* https://kentindell.github.io/2020/06/29/can-priority-inversion/&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7308</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7308"/>
		<updated>2020-10-28T21:16:51Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
==== CANdevStudio ====&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7307</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7307"/>
		<updated>2020-10-28T21:13:46Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
* https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
* https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7306</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7306"/>
		<updated>2020-10-28T21:11:34Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* stm32duino */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LIBCANARD UAVCAN library for STM32 microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=File:Can_stm32.jpg&amp;diff=7305</id>
		<title>File:Can stm32.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=File:Can_stm32.jpg&amp;diff=7305"/>
		<updated>2020-10-28T09:56:51Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7304</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7304"/>
		<updated>2020-10-28T09:54:02Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* STM32 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
[[File:can_stm32.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7303</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7303"/>
		<updated>2020-10-28T09:18:44Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* CAN-FD */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
=== can-fd-light ===&lt;br /&gt;
* https://www.st.com/content/st_com/en/about/events/events.html/can-fd-light.html&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7302</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7302"/>
		<updated>2020-10-28T09:16:47Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= rs-485 vs can bus =&lt;br /&gt;
* https://www.maximintegrated.com/content/dam/files/design/technical-documents/white-papers/can-wp.pdf &lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7301</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7301"/>
		<updated>2020-10-26T22:42:02Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* STM32 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwj0iNHpn9PsAhVPDuwKHVh-AiIQFjACegQIAxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2Fcd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&amp;amp;usg=AOvVaw2kF0T1D3TzsgvgnX7fvMku&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7300</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7300"/>
		<updated>2020-10-26T22:25:39Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
== CAN-FD ==&lt;br /&gt;
&lt;br /&gt;
The CAN-FD protocol (CAN with flexible data-rate) is an extension of the classical CAN (CAN 2.0) protocol.CAN‑FD is the CAN 2.0 successor. It efficiently supports distributed real-time control with a very high-level ofsecurity. CAN-FD was developed by Bosch and standardized as ISO 11898-1:2015 (suitable for industrial,automotive and general embedded communications)&lt;br /&gt;
&lt;br /&gt;
Improvements and benefits of CAN-FD over CAN 2.0The CAN-FD development responds to the need of communication networks that require higher bandwidth. Thisneed is fulfilled by the CAN-FD having up to 64 bytes per frame and by its possibility to increase the bitrate to upto eight times faster during the data phase, and to go back to a normal bitrate during the second arbitration phase.The data transfer integrity is ensured by:&lt;br /&gt;
* a CRC used to checksum a payload of up to 16 bytes based on 17 stage polynomial&lt;br /&gt;
* a 21-stage polynomial used to checksum the payload between 16 and 64 bytes&lt;br /&gt;
&lt;br /&gt;
CAN-FD featuresMain features of the CAN-FD protocol are listed below:&lt;br /&gt;
* Compatibility with the CAN protocol: CAN-FD node is able to send/receive CAN messages according toISO 11898-1&lt;br /&gt;
* Error-checking improvement, based on checksum field up to CRC 21 bits&lt;br /&gt;
* Prioritization of messages&lt;br /&gt;
* Guarantee of latency times&lt;br /&gt;
* Configuration flexibility&lt;br /&gt;
* Multicast reception with time synchronization&lt;br /&gt;
* System-wide data consistency up to 64 bytes per message&lt;br /&gt;
* Multimaster&lt;br /&gt;
* Error detection and signaling&lt;br /&gt;
* Distinction between temporary errors and permanent failures of nodes and autonomous switching off ofdefect nodes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://www.st.com/content/ccc/resource/training/technical/product_training/de/ee/37/c6/60/9c/45/a5/STM32L4_Peripheral_CAN.pdf/files/STM32L4_Peripheral_CAN.pdf/jcr:content/translations/en.STM32L4_Peripheral_CAN.pdf&lt;br /&gt;
* https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjaod2im9PsAhURDewKHYY3BvMQFjABegQIBxAC&amp;amp;url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00625700-fdcan-peripheral-on-stm32-devices-stmicroelectronics.pdf&amp;amp;usg=AOvVaw3jMF7ihgDGaclOGo6nlqEh&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7299</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7299"/>
		<updated>2020-10-26T17:51:08Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
CAN message filtering: &lt;br /&gt;
This library use 32 bit IDMASK filtering&lt;br /&gt;
&lt;br /&gt;
This is a good explanation of how mask and ID are handled in STM32 devices&lt;br /&gt;
https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/&lt;br /&gt;
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters&lt;br /&gt;
More around standard and extended ID&lt;br /&gt;
http://www.copperhilltechnologies.com/can-bus-guide-extended-can-protocol/&lt;br /&gt;
&lt;br /&gt;
Standard ID have a value between 0 and 0x7FF&lt;br /&gt;
Extended ID have a value between 0 and 0x1FFFFFFF&lt;br /&gt;
 &lt;br /&gt;
A CANBUS B frame (extended) consists of a four byte header (containing a 29-bit identifier), followed by up to 8 data bytes.&lt;br /&gt;
A receiving node would examine the identifier to decide if it was relevant (e.g. waiting for a frame with ID 00001567 &lt;br /&gt;
which contains data to switch on or off a motor). &lt;br /&gt;
It could do this via software (using a C if or case statement); in practice the Canbus interface contains firmware to &lt;br /&gt;
carry out this task using the acceptance filter and mask value to filter out unwanted messages.&lt;br /&gt;
The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter&lt;br /&gt;
If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.&lt;br /&gt;
If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they &lt;br /&gt;
match it is accepted otherwise the frame is rejected.&lt;br /&gt;
&lt;br /&gt;
Default this laibrary accept any frame e.g. no filters are applied&lt;br /&gt;
set filter to 0&lt;br /&gt;
set mask to 0&lt;br /&gt;
&lt;br /&gt;
Example 1. we wish to accept only frames with ID of 00001567 (hexadecimal values)&lt;br /&gt;
set filter to 00001567&lt;br /&gt;
set mask to 1FFFFFFF&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits must match; any frame that does not match ID 00001567 is rejected&lt;br /&gt;
&lt;br /&gt;
Example 2. we wish to accept only frames with IDs of 00001560 thru to 0000156F&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF0&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 3 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Example 3. we wish to accept only frames with IDs of 00001560 thru to 00001567&lt;br /&gt;
set filter to 00001560&lt;br /&gt;
set mask to 1FFFFFF8&lt;br /&gt;
&lt;br /&gt;
when a frame arrives its ID is compared with the filter and all bits except bits 0 to 2 must match; any frame other frame is rejected&lt;br /&gt;
&lt;br /&gt;
Library filter function:&lt;br /&gt;
bool setFilter( uint32_t FilterID, uint32_t FilterMask, uint8_t FilterBank, bool IDStdOrExt );&lt;br /&gt;
&lt;br /&gt;
Please read the links to figure out FilterID and FilterMask&lt;br /&gt;
FilterBank have to be defined pr. CAN interface, 0 to 13 handle Can1 message filters and 14 to 27 handle Can1 message filters&lt;br /&gt;
You alway have to start with the default filter e.g. 0 for Can1 and 14 for Can2 as they by default is set to allow all messages&lt;br /&gt;
StdOrExt define ID type, default is standard&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
We would like to recive all CAN1 messages for std ID within range 0x400 thru to 0x40f&lt;br /&gt;
Can1.setFilter( 0x400, 0x7f0, 0, IDStd );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
* https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7298</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7298"/>
		<updated>2020-10-26T17:48:12Z</updated>

		<summary type="html">&lt;p&gt;Pat1: /* STM32 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32 ====&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== &lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7297</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7297"/>
		<updated>2020-10-26T17:12:20Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://jeelabs.org/2018/canbus-intro/&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
* https://python-can.readthedocs.io/en/master/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
== CAN SPI mcp2515 ==&lt;br /&gt;
* https://www.electronicshub.org/arduino-mcp2515-can-bus-tutorial/&lt;br /&gt;
* https://www.ebay.it/itm/162281092785&lt;br /&gt;
&lt;br /&gt;
== SLCAN ==&lt;br /&gt;
* http://www.can232.com/docs/canusb_manual.pdf&lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/slcan/src/slcan.ino&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
* https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
* MCP2551 CAN transceiver IC&lt;br /&gt;
&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/schematic.png&lt;br /&gt;
&lt;br /&gt;
==== &lt;br /&gt;
* https://github.com/r-map/rmap/blob/master/platformio/test/CAN_TrafficSnooper/src/CAN_TrafficSnooper.ino&lt;br /&gt;
&lt;br /&gt;
==== exocan ====&lt;br /&gt;
* https://github.com/exothink/eXoCAN&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/canbus-exocan/src/bpCanBlinkInterrupt.ino&lt;br /&gt;
&lt;br /&gt;
==== STM32CAN ====&lt;br /&gt;
https://github.com/J-f-Jensen/libraries/tree/master/STM32CAN&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
* https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7296</id>
		<title>Gruppo Meteo/CanBus</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/CanBus&amp;diff=7296"/>
		<updated>2020-10-26T16:41:35Z</updated>

		<summary type="html">&lt;p&gt;Pat1: Creata pagina con '= estendere un bus I2C = https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf https://www.sparkfun.com/products/14589  = Can Bus = Overview  The CAN bus is an ISO standard bus o...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= estendere un bus I2C =&lt;br /&gt;
https://www.nxp.com/docs/en/data-sheet/PCA9615.pdf&lt;br /&gt;
https://www.sparkfun.com/products/14589&lt;br /&gt;
&lt;br /&gt;
= Can Bus =&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.&lt;br /&gt;
&lt;br /&gt;
* https://www.engineersgarage.com/article_page/can-protocol-understanding-the-controller-area-network-protocol/&lt;br /&gt;
&lt;br /&gt;
== Can bus in Linux ==&lt;br /&gt;
* https://elinux.org/CAN_Bus&lt;br /&gt;
* https://elinux.org/Bringing_CAN_interface_up&lt;br /&gt;
&lt;br /&gt;
== Can bus python ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== hardware ==&lt;br /&gt;
&lt;br /&gt;
=== STM32 ===&lt;br /&gt;
https://thecodeprogram.com/stm32f4---std-periphals-can-bus-with-can-interrupts&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CanOpen =&lt;br /&gt;
https://en.wikipedia.org/wiki/CANopen&lt;br /&gt;
CANopen is a communication protocol and device profile specification for embedded systems used in automation. In terms of the OSI model, CANopen implements the layers above and including the network layer. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer defined by a device profile. &lt;br /&gt;
&lt;br /&gt;
* https://github.com/curvi/CANopen&lt;br /&gt;
&lt;br /&gt;
= CANdevStudio =&lt;br /&gt;
https://github.com/GENIVI/CANdevStudio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= SAE_J1939 =&lt;br /&gt;
https://en.wikipedia.org/wiki/SAE_J1939&lt;br /&gt;
&lt;br /&gt;
= UAVCAN =&lt;br /&gt;
What is UAVCAN?&lt;br /&gt;
&lt;br /&gt;
UAVCAN is an open lightweight protocol designed for reliable intravehicular communication in aerospace and robotic applications over CAN bus, Ethernet, and other robust transports. It is created to address the challenge of deterministic on-board data exchange between systems and components of next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars.&lt;br /&gt;
&lt;br /&gt;
https://uavcan.org/&lt;br /&gt;
https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf&lt;br /&gt;
&lt;br /&gt;
https://forum.uavcan.org/t/automatic-configuration-of-port-identifiers/840/3&lt;br /&gt;
&lt;br /&gt;
== libreria per arduino ==&lt;br /&gt;
https://github.com/107-systems/107-Arduino-MCP2515&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Applicazioni Px4 ==&lt;br /&gt;
https://dev.px4.io/master/en/uavcan/&lt;br /&gt;
&lt;br /&gt;
== pyuavcan ==&lt;br /&gt;
 pyuavcan sub --transport &amp;quot;pyuavcan.transport.can.CANTransport(can.media.socketcan.SocketCANMedia('can0',8),None)&amp;quot; uavcan.node.Heartbeat.1.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== &lt;br /&gt;
&lt;br /&gt;
== UAVCAN libreria c++ semplificata per arduino ==&lt;br /&gt;
* https://github.com/107-systems/107-Arduino-UAVCAN&lt;br /&gt;
&lt;br /&gt;
== UAVCAN library for Espressif microcontrollers. (Arduino SDK) ==&lt;br /&gt;
https://github.com/JediJeremy/libuavesp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== stm32duino ==&lt;br /&gt;
https://github.com/r-map/rmap/blob/master/platformio/test/uavcan-v1/src/example.ino&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/RFC-rmap&amp;diff=7295</id>
		<title>Gruppo Meteo/RFC-rmap</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Gruppo_Meteo/RFC-rmap&amp;diff=7295"/>
		<updated>2020-10-07T13:43:56Z</updated>

		<summary type="html">&lt;p&gt;Pat1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Versione attuale pubblicata qui [https://doc.rmap.cc/rmap_rfc/rfc.html RMAP RFC]&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
	<entry>
		<id>https://www.raspibo.org/wiki/index.php?title=Discussione:Gruppo_Meteo/RFC-rmap&amp;diff=7294</id>
		<title>Discussione:Gruppo Meteo/RFC-rmap</title>
		<link rel="alternate" type="text/html" href="https://www.raspibo.org/wiki/index.php?title=Discussione:Gruppo_Meteo/RFC-rmap&amp;diff=7294"/>
		<updated>2020-10-07T13:41:24Z</updated>

		<summary type="html">&lt;p&gt;Pat1: Pat1 ha spostato la pagina Discussione:Gruppo Meteo/RFC-rmap a Discussione:Gruppo Meteo/RFC-rmap obsolete: pubblicazione su https://doc.rmap.cc/rmap_rfc/rfc.html&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#RINVIA [[Discussione:Gruppo Meteo/RFC-rmap obsolete]]&lt;/div&gt;</summary>
		<author><name>Pat1</name></author>
	</entry>
</feed>