a Curious Problem of SAM3S, Please Help me

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

Mohamad
Posts: 7
Joined: Sat Jul 12, 2014 5:40 pm

a Curious Problem of SAM3S, Please Help me

Fri Aug 22, 2014 1:46 pm

Hi Dears,
I wrote a simple LED Blinker code for my seld-designed board of SAM3S2B, and put the program on the MCU with SAM-BA.
This program will run correctly, but it appears that depends on code length to run truly. Because, on the other occasion, I add an additional code of “i=1000;” at the beginning of main function (consequently increasing code size by 4 bytes), but the problem happens after about 45 seconds of blinking, then LED will go off permanently.
Furthermore, If two instructions, “i=10000;” & “j=1000;” are added at the beginning or other places (increasing code size by 8 bytes), it never operates and blinks.
In addition, when it is blinking, if I reset the board, it will not blink anymore and I should switch the board off for more than 30-60 seconds, then turn it on again to operate correctly.
I think these all are relevant to one misconfiguration. So I cannot add extra code to my program.
How could I resolve this strange problem?
MY CODE is:
// Xtal: Default internal 4MHz
#include <SAM3S2B.h>
int main () {
int i,j;
//i=1000;
//j=10000;
PMC->PMC_WPMR = 0x504D4300;// Disable write protect
PMC->PMC_PCER0 = (1<<11);// Enable PIO clock
PIOA->PIO_PER = (1<<19); //Enable PIO
PIOA->PIO_OER = (1<<19); //Enable Output
while (1) {
PIOA->PIO_CODR = (1<<19);// Turn LED on
for (i=1;i<1000;i++) // Waiting
for (j=1;j<3000;j++);
PIOA->PIO_SODR = (1<<19);// Turn LED off
for (i=1;i<1000;i++) // Waiting
for (j=1;j<2000;j++);
}
}
FocusPaul
Posts: 29
Joined: Thu Mar 29, 2012 5:19 pm

Re: a Curious Problem of SAM3S, Please Help me

Fri Oct 17, 2014 7:32 am

Does the processor reset because of watchdog timeout? The watchdog is enabled by default, if do not disable it somewhere in your code.

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 7 guests