Need A Hint For Atmel Studio 6 + SAM3S3B

OK, I wired up a SAM3S2B power to the power rails, ground to ground, power out to the low power in, etc. Add a crystal. The thing actually works. The programmer sees it. Atmel Studio 6 can compile my program and program the chip. And it works. But it resets itself, or appears to, about every 10 seconds.

The code basically connects a 4x4 matrix, the rows are cathodes and it connects these up. The columns are anodes and it steps through them. So, 16 LEDs and 4 are lit at a time then it moves on after half a second. Very basic test. What could be causing this resetting behavior? Any ideas?

#include <asf.h>
int main (void)
	gpio_configure_pin(PIO_PB0_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PB1_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PB2_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PB3_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PA20_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PA23_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PA22_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);
	gpio_configure_pin(PIO_PA19_IDX, PIO_TYPE_PIO_OUTPUT_1 | PIO_DEFAULT);

	int i = 0;
	while (1) {
		if (i==4) i=0;


Did you leave reset just floating? Try pulling it high or low as needed.

CrossRoads: Did you leave reset just floating? Try pulling it high or low as needed.

No, I have an SPST button on NRST and a pullup and it is connected and works. Apparently you don't even need to connect it on this processor, NRST has a "Permanent Internal pull-up" according to the datasheet. I am wondering if there is some sort of watchdog timer issue here.

NRST Pin The NRST pin is bidirectional. It is handled by the on-chip reset controller and can be driven low to provide a reset signal to the external components or asserted low externally to reset the microcontroller. It will reset the Core and the peripherals except the Backup region (RTC, RTT and Supply Controller). There is no constraint on the length of the reset pulse and the reset controller can guarantee a minimum pulse length. The NRST pin integrates a permanent pull-up resistor to VDDIO of about 100 k? . By default, the NRST pin is configured as an input.

OK, I figured it out. I made another board with a SAM3X8E and it exhibits the same behavior. It seems all the Atmel ARM chips have a watchdog timer enabled by default and it trips and resets the uC when it hasn't been reset for about 12 seconds, by default. To get around it, either reset it periodically or disable it. I don't know how you do this directly with the registers, but if you are using ASF the function calls are:

wdt_restart( WDT );


wdt_disable( WDT );

The Watchdog functions have to be included using the ASF Wizard.