<div dir="ltr">hi, the size of tick is
<code>CONFIGURE_MICROSECONDS_PER_TICK</code> ?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 6, 2019 at 12:22 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jul 4, 2019 at 2:45 AM Jython <<a href="mailto:googcheng@gmail.com" target="_blank">googcheng@gmail.com</a>> wrote:<br>
><br>
> is there someone could help me<br>
><br>
I can give you some guesses.<br>
<br>
> On Sun, Jun 30, 2019 at 2:36 PM Jython <<a href="mailto:googcheng@gmail.com" target="_blank">googcheng@gmail.com</a>> wrote:<br>
>><br>
>> a 21ms counter in fact more than 10s, see log , my rtc 10s wake up<br>
>><br>
>> static void Delay_ms(x)<br>
>> {<br>
>> #if 0<br>
... // delete noise<br>
>> #endif<br>
>> volatile int i;<br>
>> int us_cnt = 1000*x;<br>
>From what you said, probably x=21, and us_cnt = 21000<br>
<br>
>> printf("delay x %dms us_cnt %d\n", x, us_cnt);<br>
>> for(i = 0; i < us_cnt; i++)<br>
>> rtems_counter_delay_nanoseconds(1000);<br>
You make 21000 calls to this function with 1000ns (1 us) per call. You<br>
should debug what is happening during a call to<br>
rtems_counter_delay_nanoseconds(1000).<br>
<br>
Some things to be aware of. The function does not disable interrupts<br>
or task switches, so if you have other tasks/interrupts, they may be<br>
scheduled and cause your delay to be even longer than you anticipate.<br>
<br>
I would check what is the granularity of your processor ability to<br>
tell time. That is, what is the size of a "tick". This function will<br>
convert the nanosecond argument to some number of ticks, and then<br>
delay at least that many ticks. One possibility is that your tick is<br>
around 500 microseconds, so each call you make is really becoming<br>
rtems_counter_delay_ticks(1) ==<br>
rtems_counter_delay_nanoseconds(500000). Thus, delay about .0005<br>
seconds per call * 21000 calls = 10.5 seconds.<br>
<br>
>><br>
>> printf("end delay\n");<br>
>> }<br>
>><br>
>><br>
>> [14:33:18.242]ÊÕ¡û¡ôflash_buf 32 00 00 00<br>
>> write page index 50<br>
>> log_page_no = 50<br>
>> before while<br>
>> loop begin<br>
>> dtr set 0<br>
>> baud 9600 at UART1_ChangeBaud<br>
>> USART_WordLength_8b<br>
>> USART_StopBits_1<br>
>> delay x 21ms us_cnt 21000<br>
>><br>
>> [14:33:21.055]ÊÕ¡û¡ôafter clr isr 00000033<br>
>><br>
>> [14:33:31.056]ÊÕ¡û¡ôafter clr isr 00000033<br>
>><br>
>> [14:33:32.759]ÊÕ¡û¡ôend delay<br>
>> Lenggui_ClrBuffer begin okflag 0<br>
>><br>
>><br>
>><br>
> _______________________________________________<br>
> users mailing list<br>
> <a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a><br>
</blockquote></div>