I have had problens with a new SAM4S based board in that it hang eraly during startup, before initializing my 12MHz xtal. Also the SWD didn't work anymore until I erased the chip. Since the SWD didn't work it was quite obvious that there is some clock related issue. I've found out that the startup code unconditionally switches to an external 32kHz xtal. On my board I didn't need one. Interestingly I had no such problem on a SAM4E board, but there is a small difference between those boards in that the SAM4E has XIN32/XOU3 pins unconnected and the SAM4S has XIN32 used as GPIO. Or maybe the SAM4E just behave differently when trying to init an unhooked 32kHz xtal. However, after commenting the sam_supcsetup() call my board worked fine. I think there should be an option to initialize the 32kHz xtal or not.
arch/arm/src/sam34/sam_clockconfig.c: /**************************************************************************** * Name: sam_supcsetup * * Description: * Select the external slow clock * ****************************************************************************/ static inline void sam_supcsetup(void) { /* Check if the 32-kHz is already selected */ if ((getreg32(SAM_SUPC_SR) & SUPC_SR_OSCSEL) == 0) { uint32_t delay; putreg32((SUPC_CR_XTALSEL | SUPR_CR_KEY), SAM_SUPC_CR); for (delay = 0; (getreg32(SAM_SUPC_SR) & SUPC_SR_OSCSEL) == 0 && delay < UINT32_MAX; delay++); } } ... /************************************************************************************ * Name: sam_clockconfig * * Description: * Called to initialize the SAM3/4. This does whatever setup is needed to put the * SoC in a usable state. This includes the initialization of clocking using the * settings in board.h. (After power-on reset, the SAM3/4 is initially running on * a 4MHz internal RC clock). This function also performs other low-level chip * initialization of the chip including EFC, master clock, IRQ & watchdog * configuration. * ************************************************************************************/ void sam_clockconfig(void) { /* Configure embedded flash access */ sam_efcsetup(); /* Configure the watchdog timer */ sam_wdtsetup(); /* Setup the supply controller to use the external slow clock */ sam_supcsetup(); /* Initialize clocking */ sam_pmcsetup(); /* Optimize CPU setting for speed */ sam_enabledefaultmaster(); } -- B.Walter <be...@bwct.de> http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.