• How to drive SAMD09 at 48MHz by 32kHz Crystal

    kodera2t06/11/2016 at 12:05 0 comments

    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"
    int main(void)
    	unsigned int i;
    	short j;
    	unsigned int multiple;
        /* Initialize the SAM system */
    	// 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, 
    //GCLK1 enabled, clock source=XOSC32k
    //DFLL48 enabled, closed-loop mode
    //DFLL multiplier setting 48MHz/32.768kHz	
    //GCLK0 enabled (main clock) source=DFLL (48MHz)
        while (1) 
    		unsigned int delay=1200000;
    		for(i=0;i<delay;i++){ //empty loop for delay
    		for(i=0;i<delay;i++){ //empty loop for delay
    		for(i=0;i<delay;i++){ //empty loop for delay
    		for(i=0;i<delay/2;i++){ //empty loop for delay
    		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!

  • How to blink your LED in simple way

    kodera2t06/10/2016 at 05:16 0 comments

    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!

  • Atmel SMART D09 was beyond my expectation!

    kodera2t05/07/2016 at 04:47 1 comment

    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!