Pages: [1]   Go Down
Author Topic: Need A Hint For Atmel Studio 6 + SAM3S3B  (Read 932 times)
0 Members and 1 Guest are viewing this topic.
Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Code:
#include <asf.h>
int main (void)
{
board_init();
sysclk_init();
delay_init(sysclk_get_cpu_hz());

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);

gpio_set_pin_low(PIO_PB0_IDX);
gpio_set_pin_low(PIO_PB1_IDX);
gpio_set_pin_low(PIO_PB2_IDX);
gpio_set_pin_low(PIO_PB3_IDX);

int i = 0;

while (1) {
gpio_set_pin_low(PIO_PA20_IDX);
gpio_set_pin_low(PIO_PA23_IDX);
gpio_set_pin_low(PIO_PA22_IDX);
gpio_set_pin_low(PIO_PA19_IDX);

i++;
if (i==4) i=0;

if(i==0)
gpio_set_pin_high(PIO_PA20_IDX);
if(i==1)
gpio_set_pin_high(PIO_PA23_IDX);
if(i==2)
gpio_set_pin_high(PIO_PA22_IDX);
if(i==3)
gpio_set_pin_high(PIO_PA19_IDX);

delay_ms(500);
}
}
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26466
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote
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.
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 );

or

wdt_disable( WDT );

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

I have only come here seeking knowledge. Things they would not teach me of in college.

Pages: [1]   Go Up
Jump to: