Outils pour utilisateurs

Outils du site


due

page de présentation: http://www.arduino.cc/en/Main/ArduinoBoardDue

schematic de la due: http://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf

emplacement des fichiers spécifiques pour la carte DUE

C:\Program Files (x86)\Arduino\hardware\arduino\sam\variants\arduino_due_x

programme principal

C:\Program Files (x86)\Arduino\hardware\arduino\sam\cores\arduino\main.cpp

inspiré de: http://forum.arduino.cc/index.php?topic=130423.0

timer0.cpp
volatile boolean l;
 
void TC0_Handler()
{
    long dummy=REG_TC0_SR0; // vital - reading this clears some flag
                            // otherwise you get infinite interrupts
    l= !l;
}
 
void setup(){
  pinMode(13,OUTPUT);
  pinMode(2,OUTPUT);    // port B pin 25  
  analogWrite(2,255);   // sets up some other registers I haven't worked out yet
  REG_PIOB_PDR = 1<<25; // disable PIO, enable peripheral
  REG_PIOB_ABSR= 1<<25; // select peripheral B
  REG_TC0_WPMR=0x54494D00; // enable write to registers
  REG_TC0_CMR0=0b00000000000010011100010000000000; // set channel mode register (see datasheet)
  REG_TC0_RC0=100000000/3; // counter period
  REG_TC0_RA0=30000000;  // PWM value
  REG_TC0_CCR0=0b101;    // start counter
  REG_TC0_IER0=0b00010000; // enable interrupt on counter=rc
  REG_TC0_IDR0=0b11101111; // disable other interrupts
 
  NVIC_EnableIRQ(TC0_IRQn); // enable TC0 interrupts
 
}
 
void loop(){
      digitalWrite(13,l);
}

avec digitalWrite 2,5us par changement d'état,

avec la commande directe des registres, 25ns par changement d'état (utiliser sonde atténuatrice 10x sur l'oscillo)

inspiré de: http://forum.arduino.cc/index.php?topic=129868.15

blink rapide.cpp
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://arduino.cc
 
  This example code is in the public domain.
 
  modified 8 May 2014
  by Scott Fitzgerald
 */
 
 
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}
 
// the loop function runs over and over again forever
void loop() {
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
  PIOB->PIO_SODR=1<<27; //lights the LED  equivalent à   PORTB |= 1<<27;
  PIOB->PIO_CODR=1<<27; //clears it
 
 
//  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  //delay(1000);              // wait for a second
  //digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  PIOB->PIO_CODR=1<<27; //clears it
 
  //delay(1000);              // wait for a second
}

sonde JTAG pour debugger

due.txt · Dernière modification : 2021/02/19 21:20 de 127.0.0.1