We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all Iam using STR912FW44 based board and I want a delay function that should give the delay in milisecond I made a function
void delay_ms (unsigned long nCount){ /* Wait function */ nCount=nCount+16000000L; while (nCount--); }
when I call
delay_ms(10000);
it gives arround 10 second delay but when I call
delay_ms(20000); it should give arround 20 second delay but it does not happen
but when I call
delay_ms(10000); delay_ms(10000);
it gives arround 15 sec delay
please tell me exact way to build a delay function
regards rupesh
First off - you should replace your "timed" busy-loop with a real delay. Tamir seems to have helped out with options.
But you should also invest some time into debugging. You are sending in a ms value into your function and then adding (!) a fixed constant. Your function will give almost the same delay even if you send in the delay value zero.
If course, you will have to _multiply_ the ms value with a constant to get the number of turns through the loop.
Just reading the code should have caught this. Stepping through the code with different input parameters should have caught this. Testing with the special case 0 should have caught this. Do spend time on debugging before asking for help. If you can't manage to figure out the problem with a single loop - how do you think you will manage to write real code?
But once more: Do _not_ use this kind of delay. A change in compiler version, compiler optimization or possibly just available register variables may totally change the speed of a loop.
tamir ,
you be gived a goodly ansewr
you be having lot of time to write!!
Ho no no no kalib...this is what I sometimes do on my way to work :-) It is part of an open-source kernel for an STR9 that I'm working on. I'll publish a link here once I am done.
hi Tamir,
does str9 support linux kernel? can we download kernel for that?
I know that the AT91SAM9261 can run embedded Linux.
The AT91SAM9261 has a core with an MMU. However, I don't think that a core like the STR912FW44 can do it because it does not have such a peripheral.
That is: ARM926EJ-S core vs. ARM966E-S core.