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
// this system call is an asynchronous call that is used to register a callback for exact // time-based notifications. any timer can serve as either in 'exact' mode or in 'poll' // mode. // 'a_index' if the index of the timer in 's_timers', a_timoeut should be given // using the MILLISECONDS_X_10 macro, 'a_timer' is a struct that contains a pointer to a // callback that shall be invoked once the timer elapses and the required parameter to be // send alog, and 'a_mode' is the timer more - must be either 'e_timer_exact_period_mode' or // 'e_timer_exact_oneshot_mode' when using the system call. // note that the first 1 + MAX_TASKS timers are dedicated to internal timers of tasks, and // should not be used for any other purpose. user timers having an index USER_TIMER_0, // USER_TIMER_1 etc. should be used instead. int32s timer_exact(int32s a_index, int32s a_timeout, timer_callback_prop_t a_timer, timer_mode a_mode) { int32u l_scheduler_state ; timer_t *lp_timer ; if ( (a_timeout < 0) || (!a_timer.callback) || ( (a_mode != e_timer_exact_period_mode) && (a_mode != e_timer_exact_oneshot_mode) ) ) { software_error("%d %s %d", ERR_INVALID_PARAMETER, __FILE__, __LINE__) ; } scheduler_disable(&l_scheduler_state) ; system_timer_disable() ; lp_timer = (s_timers + a_index) ; lp_timer->state = e_timer_ticking ; lp_timer->deadline_countdown = a_timeout ; lp_timer->period = a_timeout ; lp_timer->callback = a_timer.callback ; lp_timer->callback_parameter = a_timer.parameter ; lp_timer->mode = a_mode ; system_timer_enable() ; scheduler_restore(l_scheduler_state) ; return 0 ; }