Play With Due


It is well know that port access with Arduno-DUE running a SAM3X is far from being easy.

Transfering an Arduino-UNO project to the DUE needs a lot of research.

After that was done I managed to upload this small sketch using the lower 8 bits of register "D".

Actually, port D is the only one where you have access to bit-0. The other ones start with bit-1 or even bit-10. Still, you have to take extra care for the Serial port-#3, even if you don't use it.
/*
   http://forum.arduino.cc/index.php?topic=129868.45
   #50: NirajPrakashKini
   running light. 
   d25 --> LED-0
   d26 --> LED-1
   d27 --> LED-2
   d28 --> LED-3
   d14 --> LED-4 (TX3)
   d15 --> LED-5 (RX3)
   d29 --> LED-6 
   d11 --> LED-7
   if you use SODR you also need CODR (Clear)
   Two options:
   defining "SNAKE" or not 
*/

#define SN AKE

void setup() {
  REG_PIOD_OWER = 0xFFFFFFFF;     // Enable PORT D
  REG_PIOD_OER =  0xFFFFFFFF;     // Set PORT D as output port
  pinMode(14,OUTPUT); // TX3
  pinMode(15,OUTPUT); // RX3
  long d = 1;
  while (true) {
    //REG_PIOD_CODR = d;
    d = d * 2;
#ifdef SNAKE
    if (d < 128) d++;
#endif        
    if ((d & 255) == 0) d = 1;
    //REG_PIOD_SODR = d;
    REG_PIOD_ODSR = d;
    delay(300);
  }
}

void loop() {}



contact: nji(at)gmx.de