hello All, please help me. my code is these: #include <AT91SAM7S64.H> #include <lib_AT91SAM7S64.h> void wait(void); int main (void){ AT91F_PIO_CfgOutput(AT91C_BASE_PIOA,AT91C_PIO_PA0); AT91F_PIO_SetOutput(AT91C_BASE_PIOA,AT91C_PIO_PA0); wait(); AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,AT91C_PIO_PA0); wait(); } void wait(void){ unsigned int n; for(n=0;n<7372800;n++); } where is my problem?
You must make a endless loop in your programm. while(1) { AT91F_PIO_SetOutput(AT91C_BASE_PIOA,AT91C_PIO_PA0); wait(); AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,AT91C_PIO_PA0); wait(); }
You define
1 | unsigned int n; |
then:
1 | for(n=0;n<7372800;n++); |
unsigned int range from 0 to 65335 You need unsigned long (or unsigned long int) rangng 0 to 4294967295. Its possible the Optimicer will remove the loop
1 | for(n=0;n<7372800;n++); |
because it is empty! avr
@ avr It runs on a 32 Bit machine. ARM AT91SAM7S64 there ist "int" = 32 bit
> unsigned int range from 0 to 65335
ARM is 32Bit, so it ranges to 4G.
helmi1: Hey, why didn't I see your post before? :-)
Hossein Heidari wrote:
> where is my problem?
How can we tell if you don't tell us the manner of the failure. You
have simply said that it does not work, but in what way? Does it fail
to compile or link; does it crash, make smoke, not behave in the way you
expect? What do you expect it to do?
Either way an empty loop is a really bad way to implement a time delay;
the device has timer hardware, you should use that. Even if you do use
a loop, it is likely to get removed by the compiler optimiser when it
notices that it does nothing. To solve that you must at least declare
the counter variable as volatile.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.