user10303: I am trying to use D0/D1 as normal IO pins but DigitalWrite does not work as on an Arduino UNO.
I know the SAMD21G has SERCOM but I can't seem to find an example of not using D0/D1 as an UART port.
EDIT ** Code I have tried:
#define MYMASK 0x00000C00
void setup() {
  REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT
  REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
  delay(1000);
  REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)  
}

void loop() {
}


user490: You can do this by simply calling the right registers:
Example 1, using a MASK 
D0/D1 are mapped to to PA10 & PA11 on the M0
/* The following ports where selected
    PORT_PA11
    PORT_PA10
    */  
#define MYMASK 0x00000C00

int main (void)
{
    system_init();

    REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT
    REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
    //REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)

    while(1){       

    }   
}

Here is another simple example:
/* The following ports where selected
    PORT_PA11
    PORT_PA10
    */  
#define MYMASK 0x00000C00
#define LED1 PORT_PA10
#define LED2 PORT_PA11
int main (void)
{
    system_init();

    REG_PORT_DIRSET0 = LED1 | LED2; // Direction set to OUTPUT
    REG_PORT_OUTSET0 = LED1 | LED2; // set state of pin(s) to TRUE (HIGH)
    //REG_PORT_OUTCLR0 = LED1 | LED2; // set state of pin(s) to FALSE (LOW)
    while(1){   

    }   
}

In the Arduino IDE you can do something like:
#define MYMASK 0x00000C00
void setup() {
  REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT 
}

void loop() {
   REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
   delay(1000);
   REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)  
   delay(1000);
}


10303: <p>I am trying to use D0/D1 as normal IO pins but DigitalWrite does not work as on an Arduino UNO.</p>

<p>I know the SAMD21G has SERCOM but I can't seem to find an example of not using D0/D1 as an UART port.</p>

<p>EDIT ** <strong>Code I have tried:</strong></p>

<pre><code>#define MYMASK 0x00000C00
void setup() {
  REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT
  REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
  delay(1000);
  REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)  
}

void loop() {
}
</code></pre>
 490: <p>You can do this by simply calling the right registers:</p>

<p>Example 1, using a MASK </p>

<p>D0/D1 are mapped to to PA10 &amp; PA11 on the M0</p>

<pre><code>/* The following ports where selected
    PORT_PA11
    PORT_PA10
    */  
#define MYMASK 0x00000C00

int main (void)
{
    system_init();

    REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT
    REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
    //REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)

    while(1){       

    }   
}
</code></pre>

<p>Here is another simple example:</p>

<pre><code>/* The following ports where selected
    PORT_PA11
    PORT_PA10
    */  
#define MYMASK 0x00000C00
#define LED1 PORT_PA10
#define LED2 PORT_PA11
int main (void)
{
    system_init();

    REG_PORT_DIRSET0 = LED1 | LED2; // Direction set to OUTPUT
    REG_PORT_OUTSET0 = LED1 | LED2; // set state of pin(s) to TRUE (HIGH)
    //REG_PORT_OUTCLR0 = LED1 | LED2; // set state of pin(s) to FALSE (LOW)
    while(1){   

    }   
}
</code></pre>

<p>In the Arduino IDE you can do something like:</p>

<pre><code>#define MYMASK 0x00000C00
void setup() {
  REG_PORT_DIRSET0 = MYMASK; // Direction set to OUTPUT 
}

void loop() {
   REG_PORT_OUTSET0 = MYMASK; // set state of pin(s) to TRUE (HIGH)
   delay(1000);
   REG_PORT_OUTCLR0 = MYMASK; // set state of pin(s) to FALSE (LOW)  
   delay(1000);
}
</code></pre>
