/* p10_1: Relay control * * This program turns the relay connected to PA10 on and off every second. * * Tested with Atmel Studio 7 v7.0.1006 and Keil MDK-ARM v5.21a. */ #include "samd21.h" void delayMs(int n); int main(void) { REG_PORT_DIRSET0 = 0x00000400; /* make PA10 output */ while(1) { REG_PORT_OUTSET0 = 0x00000400; /* turn on PA10 */ delayMs(1000); REG_PORT_OUTCLR0 = 0x00000400; /* turn off PA10 */ delayMs(1000); } } /* millisecond delay based on 1 MHz system clock */ void delayMs(int n) { int i; for (; n > 0; n--) for (i = 0; i < 199; i++) __asm("nop"); }