Arduino Due: Unterschied zwischen den Versionen

Aus www.wiki.ardumower.de
Wechseln zu: Navigation, Suche
(Mega interrupt pins)
(Interrupt pins)
Zeile 57: Zeile 57:
 
  88 PK1 ADC9 PCINT17 Analog pin 09
 
  88 PK1 ADC9 PCINT17 Analog pin 09
 
  89 PK0 ADC8 PCINT16 Analog pin 08
 
  89 PK0 ADC8 PCINT16 Analog pin 08
 +
 +
 +
=PWM frequencies=
 +
For Arduino Uno, Nano, Micro Magician, Mini Driver, Lilly Pad and any other board using ATmega 8, 168 or 328**
 +
 +
//---------------------------------------------- Set PWM frequency for D5 & D6 -------------------------------
 +
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to    1 for PWM frequency of 62500.00 Hz
 +
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to    8 for PWM frequency of  7812.50 Hz
 +
  TCCR0B = TCCR0B & B11111000 | B00000011;    // set timer 0 divisor to    64 for PWM frequency of  976.56 Hz (The DEFAULT)
 +
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to  256 for PWM frequency of  244.14 Hz
 +
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz 
 +
//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------
 +
//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to    8 for PWM frequency of  3921.16 Hz
 +
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of  490.20 Hz (The DEFAULT)
 +
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz
 +
//---------------------------------------------- Set PWM frequency for D3 & D11 ------------------------------
 +
//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to    8 for PWM frequency of  3921.16 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of  980.39 Hz
 +
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of  490.20 Hz (The DEFAULT)
 +
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to  128 for PWM frequency of  245.10 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz
 +
 +
//For Arduino Mega1280, Mega2560, MegaADK, Spider or any other board using ATmega1280 or ATmega2560**
 +
//---------------------------------------------- Set PWM frequency for D4 & D13 ------------------------------
 +
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to    1 for PWM frequency of 62500.00 Hz
 +
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to    8 for PWM frequency of  7812.50 Hz
 +
  TCCR0B = TCCR0B & B11111000 | B00000011;    <// set timer 0 divisor to    64 for PWM frequency of  976.56 Hz (Default)
 +
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to  256 for PWM frequency of  244.14 Hz
 +
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz
 +
//---------------------------------------------- Set PWM frequency for D11 & D12 -----------------------------
 +
//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to    8 for PWM frequency of  3921.16 Hz
 +
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of  490.20 Hz
 +
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz
 +
//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------
 +
//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to    8 for PWM frequency of  3921.16 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of  980.39 Hz
 +
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of  490.20 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to  128 for PWM frequency of  245.10 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz
 +
//---------------------------------------------- Set PWM frequency for D2, D3 & D5 --------------------------- 
 +
//TCCR3B = TCCR3B & B11111000 | B00000001;    // set timer 3 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR3B = TCCR3B & B11111000 | B00000010;    // set timer 3 divisor to    8 for PWM frequency of  3921.16 Hz
 +
  TCCR3B = TCCR3B & B11111000 | B00000011;    // set timer 3 divisor to    64 for PWM frequency of  490.20 Hz
 +
//TCCR3B = TCCR3B & B11111000 | B00000100;    // set timer 3 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR3B = TCCR3B & B11111000 | B00000101;    // set timer 3 divisor to  1024 for PWM frequency of    30.64 Hz
 +
//---------------------------------------------- Set PWM frequency for D6, D7 & D8 ---------------------------
 +
//TCCR4B = TCCR4B & B11111000 | B00000001;    // set timer 4 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR4B = TCCR4B & B11111000 | B00000010;    // set timer 4 divisor to    8 for PWM frequency of  3921.16 Hz
 +
  TCCR4B = TCCR4B & B11111000 | B00000011;    // set timer 4 divisor to    64 for PWM frequency of  490.20 Hz
 +
//TCCR4B = TCCR4B & B11111000 | B00000100;    // set timer 4 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR4B = TCCR4B & B11111000 | B00000101;    // set timer 4 divisor to  1024 for PWM frequency of    30.64 Hz
 +
//---------------------------------------------- Set PWM frequency for D44, D45 & D46 ------------------------
 +
//TCCR5B = TCCR5B & B11111000 | B00000001;    // set timer 5 divisor to    1 for PWM frequency of 31372.55 Hz
 +
//TCCR5B = TCCR5B & B11111000 | B00000010;    // set timer 5 divisor to    8 for PWM frequency of  3921.16 Hz
 +
  TCCR5B = TCCR5B & B11111000 | B00000011;    // set timer 5 divisor to    64 for PWM frequency of  490.20 Hz
 +
//TCCR5B = TCCR5B & B11111000 | B00000100;    // set timer 5 divisor to  256 for PWM frequency of  122.55 Hz
 +
//TCCR5B = TCCR5B & B11111000 | B00000101;    // set timer 5 divisor to  1024 for PWM frequency of    30.64 Hz

Version vom 4. März 2015, 17:53 Uhr

Pinout

Changes for Arduino Due

  1. Each Arduino Due I/O pin can provide a current of 3mA or 15mA (see pin mapping). Transistors may be needed for LEDs, speaker etc.
  2. The Arduino Due runs at 3.3V. Therefore, all signal lines also need to run at 3.3V:


Module 5V signal output-----10k---+---20k---GND
                                  | 
                                  |
                    Arduino Due 3.3V signal input


Following modules and pins use 5V signal output:

  Module                   Signal output
  Pre-amplifier LM386      OUT
  Motor driver MC33926     M1_FB, M2_FB
  Ultrasonic HC-SR04       Echo


Following modules already use 3.3V signal output (and use 3.3V compatible signal inputs):

  Module                   Signal output
  WIFI ESP8266             TX
  Bluetooth HC-05          TX
  GPS GY-NEO6MV2           TX
  IMU GY-80                SDA
  RTC DS1307               SDA
  Current sensor INA169    OUT


Interrupt pins

The Due can generate an interrupt on any pin, the Mega 2560 only on the following pins:

6	PE4	OC3B	INT4		Digital pin 02	PWM		
7	PE5	OC3C	INT5		Digital pin 03	PWM		
19	PB0	SS	PCINT0		Digital pin 53		SS	(SPI Slave Select input or Pin Change Interrupt 0)
20	PB1	SCK	PCINT1		Digital pin 52		SCK	(SPI Bus Serial Clock or Pin Change Interrupt 1)
21	PB2	MOSI	PCINT2		Digital pin 51		MOSI	(SPI Bus Master Output/Slave Input or Pin Change Interrupt 2)
22	PB3	MISO	PCINT3		Digital pin 50		MISO	(SPI Bus Master Input/Slave Output or Pin Change Interrupt 3)
23	PB4	OC2A	PCINT4		Digital pin 10	PWM		
24	PB5	OC1A	PCINT5		Digital pin 11	PWM		
25	PB6	OC1B	PCINT6		Digital pin 12	PWM		
26	PB7	OC0A	PCINT7	OC1C	Digital pin 13	PWM		
82	PK7	ADC15	PCINT23		Analog pin 15			
83	PK6	ADC14	PCINT22		Analog pin 14			
84	PK5	ADC13	PCINT21		Analog pin 13			
85	PK4	ADC12	PCINT20		Analog pin 12			
86	PK3	ADC11	PCINT19		Analog pin 11			
87	PK2	ADC10	PCINT18		Analog pin 10			
88	PK1	ADC9	PCINT17		Analog pin 09			
89	PK0	ADC8	PCINT16		Analog pin 08


PWM frequencies

For Arduino Uno, Nano, Micro Magician, Mini Driver, Lilly Pad and any other board using ATmega 8, 168 or 328**

//---------------------------------------------- Set PWM frequency for D5 & D6 ------------------------------- 
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to     1 for PWM frequency of 62500.00 Hz
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to     8 for PWM frequency of  7812.50 Hz
  TCCR0B = TCCR0B & B11111000 | B00000011;    // set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (The DEFAULT)
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to   256 for PWM frequency of   244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz  
//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------ 
//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of   490.20 Hz (The DEFAULT)
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz 
//---------------------------------------------- Set PWM frequency for D3 & D11 ------------------------------ 
//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to     8 for PWM frequency of  3921.16 Hz
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of   980.39 Hz
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of   490.20 Hz (The DEFAULT)
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to   128 for PWM frequency of   245.10 Hz
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz

//For Arduino Mega1280, Mega2560, MegaADK, Spider or any other board using ATmega1280 or ATmega2560** 
//---------------------------------------------- Set PWM frequency for D4 & D13 ------------------------------ 
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to     1 for PWM frequency of 62500.00 Hz
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to     8 for PWM frequency of  7812.50 Hz
  TCCR0B = TCCR0B & B11111000 | B00000011;    <// set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (Default)
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to   256 for PWM frequency of   244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz
//---------------------------------------------- Set PWM frequency for D11 & D12 ----------------------------- 
//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz 
//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------ 
//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to     8 for PWM frequency of  3921.16 Hz
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of   980.39 Hz
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to   128 for PWM frequency of   245.10 Hz
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz
//---------------------------------------------- Set PWM frequency for D2, D3 & D5 ---------------------------  
//TCCR3B = TCCR3B & B11111000 | B00000001;    // set timer 3 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR3B = TCCR3B & B11111000 | B00000010;    // set timer 3 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR3B = TCCR3B & B11111000 | B00000011;    // set timer 3 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR3B = TCCR3B & B11111000 | B00000100;    // set timer 3 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR3B = TCCR3B & B11111000 | B00000101;    // set timer 3 divisor to  1024 for PWM frequency of    30.64 Hz
//---------------------------------------------- Set PWM frequency for D6, D7 & D8 --------------------------- 
//TCCR4B = TCCR4B & B11111000 | B00000001;    // set timer 4 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR4B = TCCR4B & B11111000 | B00000010;    // set timer 4 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR4B = TCCR4B & B11111000 | B00000011;    // set timer 4 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR4B = TCCR4B & B11111000 | B00000100;    // set timer 4 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR4B = TCCR4B & B11111000 | B00000101;    // set timer 4 divisor to  1024 for PWM frequency of    30.64 Hz
//---------------------------------------------- Set PWM frequency for D44, D45 & D46 ------------------------ 
//TCCR5B = TCCR5B & B11111000 | B00000001;    // set timer 5 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR5B = TCCR5B & B11111000 | B00000010;    // set timer 5 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR5B = TCCR5B & B11111000 | B00000011;    // set timer 5 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR5B = TCCR5B & B11111000 | B00000100;    // set timer 5 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR5B = TCCR5B & B11111000 | B00000101;    // set timer 5 divisor to  1024 for PWM frequency of    30.64 Hz