SAM4S Xplained PRO Examples not working.

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I either have a fried board or something has changed on atmel's side since I last programmed these boards.  Code that was working fine a year ago no longer boots.

 

I tried to go back to basics and loaded up sample projects.  The one currently being used is the LOW_POWER example.  This also fails to load up or print anything out to console.  I booted up the debugger and they cough and croak in PLL0 initialization, specifically the last line of the main clock switch:


void pmc_switch_mainck_to_xtal(uint32_t ul_bypass,
		uint32_t ul_xtal_startup_time)
{
	/* Enable Main Xtal oscillator */
	if (ul_bypass) {
		PMC->CKGR_MOR = (PMC->CKGR_MOR & ~CKGR_MOR_MOSCXTEN) |
				CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCXTBY |
				CKGR_MOR_MOSCSEL;
	} else {
		PMC->CKGR_MOR = (PMC->CKGR_MOR & ~CKGR_MOR_MOSCXTBY) |
				CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCXTEN |
				CKGR_MOR_MOSCXTST(ul_xtal_startup_time);
		/* Wait the Xtal to stabilize */
		while (!(PMC->PMC_SR & PMC_SR_MOSCXTS));

		PMC->CKGR_MOR |= CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCSEL;
	}
}

When the program writes to PMC->CKGR_MOR, the whole thing comes crashing down.

 

Anyone else having issues?  I've bought another SAM board, and another USB cable (will arrive in two days) to rule out hardware.

 

Last Edited: Sat. Mar 28, 2020 - 12:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check the status of GPNVM#1. If it's zero (the default from new, or after ERASE) then the device will run the SAM-BA boot loader straight out of reset rather than your code in Flash.

 

If SAM-BA detects an external crystal of the appropriate frequency, it will enable it and switch the main clock to it in order to provide USB support.

 

It's possible your debugger session does not fully reset the device, thus the clock selection/PLL hardware is not in the state expected by your firmware. I've seen the same problem on SAM4S here.

 

Steve

 

 

 

Maverick Embedded Technologies Ltd. Home of Maven and wAVR.

Maven: WiFi ARM Cortex-M Debugger/Programmer

wAVR: WiFi AVR ISP/PDI/uPDI Programmer

https://www.maverick-embedded.co...