ATSAMD21G18A RAW MICRO not working with Zero Arduino Lib??? (HELP!)

Ok what am I doing wrong?

I've been able to successfully program the micro using atmel.start and get a blinking LED and use the USART.
But I want to integrate the Arduino libraries and develop in cpp. I did the import of a Zero project and it will program successfully via Atmel Studio 7 using SWD. I can even step through the code in debug mode but I cannot get any of the ports to do anything?

What am I doing wrong that atmel.start allows me to have a running micro but a zero sketch will not function?
This is not a zero board, it's just using the same micro.

Any help is much appreciated. I want to move away from AVR's and start using ARMs but this is really frustrating.

Thanks,
Mark

You must build and link the arduino program to start at address 0x0000 if you don't have the Arduino bootloader installed. Go to the ld file and replace this line :

 FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */

by this one :

 FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 /* The program works without bootloader*/

AloyseTech

I'm having a similar problem to Jaxxs so I am following your advice. Excuse me for being slow on the Arduino stuff but my previous experience has been with logic devices so this is all new to me.

The .ld file does not seem to be a straight text file and it will not open with the Arduino IDE but it will open under Atmel 7.
Do I just edit and save under Atmel or is there a build process I should be following?

Second, if I program the micro. directly using SWD I do not need the bootloader for programming but are there any other system settings made by the original, now unused, bootloader that I need?
Following other posts there are references to the bootloader setting fuses and clock speeds etc. does this apply to a fresh SAMD21 micro or is that an AVR thing?

Many thanks for your invaluable traing. Brian

AloyseTech

I checked the toolchain and it has a link to the "flash_without_bootloader.id" which is written as you have indicated.
This is located in the folder linker_scripts\gcc\flash_without_bootloader.id

MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
}

And is referred to under ARM/GNU Linker.

I check the atmel.start project and it has the following

MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

I tried this but no luck.

So still no joy getting it to run correctly?

Cheers,
Mark

Would it have anything to do with the clock since I'm not using a Zero and I'm using the internal clock of the SAMD21?

Ok so I can confirm that it's the clock settings in the startup.c found in src\core\startup.c

If comment out everything inside

void SystemInit( void ){

}

and simply place SystemCoreClock = 1000000;

I'm now able to flash the chip and run everything successfully....so far.