Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Control Machine Cycle
PostPosted: Fri Aug 19, 2011 12:18 pm 
Offline

Joined: Mon Aug 15, 2011 8:14 pm
Posts: 2
Hi Friends

I'm Starter in Atmel ARM Programming. I Write a simple Project, in this project I turn On 3 LEDs Step by Step, at the end I turn off these LEDs. now I have problem with Machine Cycle, My Project Work normally but after Several Second my Micro Reset and Restart Again, I think after several Minute My Micro Complete machine Cycle and Restart Again.

My question is, how do I can reset Machine Cycle at the end of my Project Loop?

this is my Project Source:

#include <AT91SAM7s256.H> /* AT91SAMT7S64 definitions */

int n;
void delay(void);

int main (void)
{

*AT91C_PIOA_PER = 0xFFFFFFFF; // Set in PIO mode
*AT91C_PIOA_OER = 0xFFFFFFFF; // Configure in Output
*AT91C_PIOA_OWER = 0xFFFFFFFF;


*AT91C_PIOA_SODR = 0x00000001 ;
delay();
*AT91C_PIOA_SODR = 0x00000040 ;
delay();
*AT91C_PIOA_SODR = 0x00001000 ;
delay();
*AT91C_PIOA_CODR = 0x00001000 ;
delay();
*AT91C_PIOA_CODR = 0x00000040 ;
delay();
*AT91C_PIOA_CODR = 0x00000001 ;
delay();

}
void delay (void){
for (n=0; n<2500; n++);
}

I Use 18.423 MHz Crystal.


Top
 Profile  
 
 Post subject: Re: Control Machine Cycle
PostPosted: Fri Aug 19, 2011 3:31 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
You shouldn't exit the main() function. It doesn't go anywhere you want it to go.

Put a "while(1);" at the end for it to spin in an infinite loop.


Top
 Profile  
 
 Post subject: Re: Control Machine Cycle
PostPosted: Fri Aug 19, 2011 4:39 pm 
Offline

Joined: Mon Aug 15, 2011 8:14 pm
Posts: 2
[quote="CptTitanic"]You shouldn't exit the main() function. It doesn't go anywhere you want it to go.

Put a "while(1);" at the end for it to spin in an infinite loop.[/quote]

thanks for answer. but if I use your way, I had just one cycle.

I use while(1) for all of my Instruction, but after several second reset Program between my cycle.

I change the delay time (100) and help me invisible reset time.


Top
 Profile  
 
 Post subject: Re: Control Machine Cycle
PostPosted: Fri Aug 19, 2011 5:04 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Your English is very tortured.

What do you want the code to do? Run repeatedly? Reset periodically?

Want it to cycle the GPIO pins continuously, then :

while(1)
{
*AT91C_PIOA_SODR = 0x00000001 ;
delay();
*AT91C_PIOA_SODR = 0x00000040 ;
delay();
*AT91C_PIOA_SODR = 0x00001000 ;
delay();
*AT91C_PIOA_CODR = 0x00001000 ;
delay();
*AT91C_PIOA_CODR = 0x00000040 ;
delay();
*AT91C_PIOA_CODR = 0x00000001 ;
delay();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: