Arduino Due Initialization

Hi,

I'm new to Arduino and I'm little bit confused about start up initialization. Is there any information on how DUE is initializated? Especially I'm wondering if it starts at 84MHz or I have to set up PLL myself?

I think arduino_due_x/variant.cpp is file where some initialization is done, but then it use SystemInit(), but I'm not able to find this function quickly.

Thanks for any suggestion.

BR,
Krzysiek

I don't know if it is the exact file used, but look at hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/source/system_sam3xa.c - there looks like there is some clock setting code in there.

There's a call to init() in main()

C:\arduino-1.5\hardware\arduino\sam\cores\arduino\main.cpp

It's bound to be in there even if you have to follow the train of calls for a while. But for the life of me I can't find where init() is.

It probably winds up at SystemInit() in the file Stimmer mentioned, but it would be nice to know.

EDIT:
There's a main() in this file that calls SystemInIt() directly

C:\arduino-1.5\hardware\arduino\sam\system\CMSIS\Examples\cmsis_example\main.c

But the first main() I pointed to seem to be the Arduino entry point.


Rob

I'd add that from my experiments with timers and VGA, the clock is definitely running at 84MHz by the time setup is called.

Many thanks for replay.

It looks like 'hardware/arduino/sam/cores/arduino' is an Arduino part with the entry point main.cpp. Then, I think initialization of MCU is done in init() function from 'hardware/arduino/sam/variants/arduino_due_x/variant.cpp'.

The init() uses SystemInit() function, it's probably from 'hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/source/system_sam3xa.c'.

It seems that this CMSIS folder contains some standard libraries provided by ARM: http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php.

'hardware/arduino/sam/system/libsam/' is also interesting, it contains functions to use some pheripherals, like RTC, SPI or Watchdog.

Regards,
Krzysiek

as you already discovered, the Reset_Handler function is the entry point.

I also patched the file above:

the reason is that __libc_init_array() initializes all static c++ objects (by calling their constructor), and some libraries
(for instance LiquidCrystal) uses delay() inside constructors, and delay() didnt work (hangs the CPU) if the hardware is not
initalized before.

C