Selfmade Due running way to slow

Hi!

I build my own Due Board (kind of). I programmed it using an J-Link (SWD). My first try was uploading the Blink sketch. When trying to Blink with Output Digital 50, it way to slow! When I set the Sketch to have an Intervall of 1 sec, the Due actually takes 6 sec to do it!

I uploaded the sketch (as I said) using my Segger J-Link and AtmelStudio with the Arduino DUE Project file selected. What could that be? are there any fuses I need to set?

tsaG:
Hi!

I build my own Due Board (kind of). I programmed it using an J-Link (SWD). My first try was uploading the Blink sketch. When trying to Blink with Output Digital 50, it way to slow! When I set the Sketch to have an Intervall of 1 sec, the Due actually takes 6 sec to do it!

You probably didn't set the proper CPU clock speed.

tsaG:
are there any fuses I need to set?

Yes.

for optiboot with 8mhz internal clk i found h=d6 l=e2 best. for 16mhz crystal i use h=d6 l=a7. these preserve ee on download as opposed to arduino settings which, for some peculiar reason, destroy the ee data every time.

Hi,

thanks for the fast response. Im using an 12mhz and 32.xxkhz Crystal. The Sam3x8e doesnt use Optiboot.
Also, I cant find the Fuse settings, the only bits I can set are the GPNVM and Lockbits.
Where do I have to look? Do I need any other external tools?

tsaG:
Hi,

thanks for the fast response. Im using an 12mhz and 32.xxkhz Crystal. The Sam3x8e doesnt use Optiboot.
Also, I cant find the Fuse settings, the only bits I can set are the GPNVM and Lockbits.
Where do I have to look? Do I need any other external tools?

For weird crystals you might have to edit "boards.txt" and create a new entry for your board/crystal (set F_CPU).

But the Due also uses an 12mhz fast and 32.768 Slow Crystal :frowning:

Sorry for doupleposting, but could anyone look on their Due to tell me which Crystal is installed? I read several Threads where it says there is an 16mhz Crystal, which would explain the whole thing here.

The SAM3X crystal is 12MHz. It doesn't have fuses, instead the clock speed is set by the PLL registers. To get 84MHz you set some register somewhere to multiply the crystal frequency by 7. I don't know any more about it than that though.

Do you call Atmel's SystemInit() function from your main() ?
This is called from the Arduino main.c, and appears to setup default system clock behavior.
Normally, I would think that code should call sysclk_init() from the asf library (at least, if you're using asf (which arduino does)), but I don't see that in the arduino startup.
The actual code is in ...hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/source/system_sam3xa.c

tsaG:
Sorry for doupleposting, but could anyone look on their Due to tell me which Crystal is installed? I read several Threads where it says there is an 16mhz Crystal, which would explain the whole thing here.

Hmm, I've built a Due barebones some time ago.. And the blink sketch is working AÒK!! Here is the thread: [Solved] Help with ATSAM3X8E (Due barebones) - Microcontrollers - Arduino Forum.. I used 12MHz and 32.768kHz crystals...

Hullo tsag . I have been trying to connect board work to the J-Link Segger ......... it detects the board but it does nt do anything else , it says failed to read or write ... and it detects wrong core ID ...... so can u plz tell me how u made it work? .... (I have J-Flash V 4.5 as the software for the J link )