Go Down

Topic: Switching to the external 12MHz oscillator  (Read 958 times) previous topic - next topic

weird_dave

I have some boards made which I have replaced the external x'tal with an oscillator. I can upload code but the micro fails to run the code when it switches to the external oscillator. I know that I need to config the registers to tell it to be in bypass mode, the thing I can't figure out is where to do it, obviously it needs to happen before the changeover.
I can see in variant.cpp a call to SystemInit(), I think it's in there but I have been unable to locate the code so that I can alter it as appropriate.
If anyone can shed some light on this that would be great.

westfw

SystemInit() is off in  .../packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL/sam3xa/source/system_sam3xa.c
(It does include the clock initialization.)
(and yeah, I don't think that's a good place for it either.)


weird_dave

That's fantastic! (The fact that I now have the answer, not the location obviously ;) )
Thanks :)

weird_dave

Well, I was a little too quick to reply, I don't have that file path, but I did locate it in:
..\packages\arduino\hardware\sam\1.6.9\system\CMSIS\Device\ATMEL\sam3xa\source\system_sam3xa.c

weird_dave

Unfortunately, I have a follow-on question. How do you get the Arduino IDE to recompile system_sam3xa.c ? It never appears in the verbose output.

westfw

I'm not sure.  I think it gets built into libsam, which is in hardware/sam/<version>/system/ - there's some "build" directories there, with makefiles and stuff.  (oh an look!  Another copy of system_sam3xa.c !)

weird_dave

Hehehe, what a mess :)
I've cheated and commented out SystemInit() then copy/pasted the code from that directly into variant.cpp and modified it, works like a charm :)
Cheers :)

Go Up