I found Atmel SAMD09 is lowest price ARM Cortex M0+ MCU in digikey. Compared to another low-end ARM (ex. LPC810), SAMD09 has more rich I/O including 12 bit A/D up to 10 channels, I2C, USART, SPI and more. No reason to avoid it!!
I've known Atmel SMART has DFLL (Digital Frequency Locked Loop), which can drive full speed (48 MHz) by 32.768 kHz. I know this operation by hardware since,,
Some people might have some memory of some guy made SD card sized Arduino Zero compatible "card", where just 32.768 kHz crystal is implemented but powerful SAM D21 is working at 48 MHz. But actually I did not grasp the fundamentals but just made a "reduced" Arduino Zero, indeed.
My current interest is not making something copy but understanding and handling Atmel SMART SAM D09 from root, as possible. As we can see, already 32.768 kHz crystal and 22 pF capacitors are already put on it and this time I finally enabled it and currently my board is working at 48 MHz, as same as Arduino Zero.
#include "sam.h"intmain(void){
unsignedint i;
short j;
unsignedint multiple;
multiple=48000000/32768;
/* Initialize the SAM system */
SystemInit();
// setting PA02, PA04, PA05, PA14 for output DIR
REG_PORT_DIR0 |= ((1<<2)+(1<<4)+(1<<5));
REG_PORT_OUTSET0 = (1<<2)+(0<<4)+(1<<5);
// enable external 32.768kHz crystal// crystal en, startup time 65536, 32k_out en,
REG_SYSCTRL_XOSC32K=(1<<1)+(1<<2)+((0x6)<<8)+(1<<7)+(1<<5)+(0<<4)+(1<<3)+(0<<6);
//GCLK1 enabled, clock source=XOSC32k
REG_GCLK_GENCTRL=0x0000+(0<<21)+(0<<19)+(1<<16)+(0x05<<8)+(0x1);
//DFLL48 enabled, closed-loop mode
REG_SYSCTRL_DFLLCTRL=0x00+(0<<9)+(0<<8)+(0<<7)+(1<<2)+(1<<1);
//DFLL multiplier setting 48MHz/32.768kHz
REG_SYSCTRL_DFLLMUL=((0x1F/4)<<26)+((0x1F/4)<<16)+multiple;
//GCLK0 enabled (main clock) source=DFLL (48MHz)
REG_GCLK_GENCTRL=0x0000+(0<<21)+(0<<19)+(1<<16)+(0x07<<8)+(0x0);
while (1)
{
unsignedint delay=1200000;
REG_PORT_OUT0=0b100000;
for(i=0;i<delay;i++){ //empty loop for delay
}
REG_PORT_OUT0=0b010000;
for(i=0;i<delay;i++){ //empty loop for delay
}
REG_PORT_OUT0=0b000100;
for(i=0;i<delay;i++){ //empty loop for delay
}
for(j=0;j<3;j++){
REG_PORT_OUT0=0b110100;
for(i=0;i<delay/2;i++){ //empty loop for delay
}
REG_PORT_OUT0=0b000000;
for(i=0;i<delay/2;i++){ //empty loop for delay
}
}
}
}
Before while(1) loop, I just wrote DFLL setting. If the board is working at default internal RC oscillator, LED blinking is veeeery slow but if it works well, blinking time is moderate. Have fun and try!
As I did it in AVR project, I always don't like putting something "unclear thing" between me and MCU. Ultimately machine code or assembly is ideal for this purpose and...
I bought several books but none of them shows me a straightforward guidance of my tiny SAMD09 board programming. Atmel seems to have a good support of their Xplained board series but nothing is clear for home-brew SAMD09 board.. (as far as I read and googled).
As a result, I read and find how to control PORT of SAMD09 at page 370 of SAMD09 data sheet and finally I could drive my board by own code, without any "unclear library". Here is the way...
Firstly we can make "new project" in Atmel Studio as "GCC Executable Project". NOT ASF (Atmel Software Framework) project.
Proudly we can choose "SAMD09" as device family and select the cheapest ARM chip, ATSAMD09C13A, HooHoo.
This is the default code made by above setting. Actually SystemInit() is a initialisation code and which is unclear but I dare to accept it.
We can write this very simple code driving LED connected to PA04 (14 Pin of SAMD09). REG_PORT_DIR0 defines data direction of GPIO port 4 (this case PA04 for output) and toggling port with interval defined by consuming time of empty loop of 100000.
Writing binary through ATmel ICE. Atmel ICE is indispensable for Atmel ARM and AVR!
Finally you will get LED blink by your own board and code. Currently 32.768kHz crystal is not activated and just SAMD09 with SOP-DIP conversion board is enough to fundamental check. Have fun!
I've knew Atmel's Cortex M0+ series (SAMD21) and used for making Arduino Zero compatible in another project. SAMD21 has quite rich I/O and even natively support USB interface, no need of FTDI. This time, I found one thing that Atmel's SAMD09 is lowest price of Cortex M0+.
Before I used LPC810, which is a kind of low-price leader but SAMD09 has additional SRAM (4kB) and flash (8kB) and moreover, 12 bit A/D converter! even such a low price!
I don't (cannot) buy 3000pcs and checked price for single pieces and it is still 1.15 USD, and quickly ordered it and...
I've got them. Always I prefer "printed" data sheet for quick reference but this tiny chip has more than 700 pages data sheet!! (I notice nowadays is paperless and Atmel also does not expect to be printed out by paper, though...)
Here is actual chip shape. very small "ARM" logo can be found on it!
I quickly draw schematic for prototyping. SAMD09 has internal oscillator but I dare to put crystal for future interest. Programming can be done through Atmel ICE...
Here is the prototyping board I made. As an initial test, I uploaded LED blinking program driving 4 LEDs connecting PA2, PA4, PA24 and PA25.
The following movie will show you actual operation of this prototyping board. This project is about my learning process of SAMD09 and may not contain novelty but if you see something useful, I am very happy. Have fun!
I want to know how you have burned boot loader? I have problem in burning boot loader.