SAM4S16 bricked after programming?

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Physikant
Posts: 3
Joined: Sat Oct 11, 2014 1:31 am

SAM4S16 bricked after programming?

Fri May 01, 2015 5:49 pm

Hello,
I'm using a SAM4S16B on a custom made board. I've connected a 12MHz 3V3-Crystal oscillator and a 32,768kHz slowclock-crystal.

The SAM is connected via JTAG and Atmel ICE and I was able to read the device signature and erase the memory, no problems at all. Then I wanted to program the SAM, so I used the following basic startup code:

Code: Select all

EFC0->EEFC_FMR = EEFC_FMR_FWS(1);
	#if defined(ID_EFC1)
	EFC1->EEFC_FMR = EEFC_FMR_FWS(1);
	#endif
	
	
	SUPC->SUPC_CR =	 (0xA5u << 24) 
	|SUPC_CR_XTALSEL_CRYSTAL_SEL
	;
	while(!(SUPC->SUPC_SR & SUPC_SR_OSCSEL));
	
	
	if (!(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL))
	{
		PMC->CKGR_MOR = (0x37u << 16) 
		| CKGR_MOR_MOSCXTBY	
		| CKGR_MOR_MOSCSEL
		| CKGR_MOR_CFDEN	
		;
		while (!(PMC->PMC_SR & PMC_SR_MOSCSELS)) {} 
		while (!(PMC->PMC_SR & PMC_SR_MOSCXTS)) {} 
	}
	
	
	PMC->CKGR_PLLAR =
	CKGR_PLLAR_ONE				
	|CKGR_PLLAR_DIVA(1)
	|CKGR_PLLAR_MULA(9)
	|CKGR_PLLAR_PLLACOUNT(63)
	;
	while (!(PMC->PMC_SR & PMC_SR_LOCKA)) {}
	
	
	PMC->PMC_MCKR = PMC_MCKR_CSS_PLLA_CLK;
	while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {}
	
	REG_WDT_MR = WDT_MR_WDDIS; 
	
	PMC->CKGR_MCFR = CKGR_MCFR_RCMEAS; 
	while(!(PMC->CKGR_MCFR & CKGR_MCFR_MAINFRDY)){}
	uint32_t result = PMC->CKGR_MCFR & CKGR_MCFR_MAINF_Msk;
	PMC->CKGR_MCFR = CKGR_MCFR_RCMEAS; 
	while(!(PMC->CKGR_MCFR & CKGR_MCFR_MAINFRDY)){} 
	result = PMC->CKGR_MCFR & CKGR_MCFR_MAINF_Msk; 
	/*
		//frequency error handling goes here, but will probably never be done :)
	*/
	SystemCoreClock = 120000000UL; 
After programming that code, the controller didn't start up anymore. I tried to erase the controller by connecting the erase-pin to 3V3 while performing a power cycle, nothing changed. The device just can't be found anymore. Even VCCcore is 0V now. Is there any explanation for that? Anything I can avoid in the future?
Best regards,
Nikolas

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest