[riot-devel] xtimer problem

Joakim NohlgÄrd joakim.nohlgard at eistec.se
Thu Apr 7 17:15:50 CEST 2016


I noticed that you wrote %.2 for the format of the number. The period (".")
doesn't make sense in a format string for integer variables. Does it crash
if you change the format string to only "%" or "%2" PRIu32?
On Apr 7, 2016 4:29 PM, "Theodore Kotsonis" <kotsonis at aueb.gr> wrote:

> Hi everyone
>
> I am trying to use xtimer method. I want to calculate how much miliseconds
> do my function.
> Is there any xtimer counter to use?
>
> I tried to use uint43 xtimer_now before and after the method but when I do
> the subtraction I get the result but then I get an error on my board
> Below is my code
>
>     first_wakeup = xtimer_now();
>     printf("%" PRIu32 "\n", first_wakeup);
>     /*my method*/
>     last_wakeup = xtimer_now();
>     final_result = last_wakeup -
>     printf("%.2" PRIu32 "\n", last_wakeup - first_wakeup);
>
> and this is the error
>
> 2016-04-07 14:06:16,042 - INFO # Context before hardfault:
> 2016-04-07 14:06:16,043 - INFO #    r0: 0x00000000
> 2016-04-07 14:06:16,048 - INFO #    r1: 0xf134b7e4
> 2016-04-07 14:06:16,048 - INFO #    r2: 0x00000328
> 2016-04-07 14:06:16,054 - INFO #    r3: 0x2000018c
> 2016-04-07 14:06:16,055 - INFO #   r12: 0x00000000
> 2016-04-07 14:06:16,055 - INFO #    lr: 0x08000fd3
> 2016-04-07 14:06:16,055 - INFO #    pc: 0x08000fe4
> 2016-04-07 14:06:16,055 - INFO #   psr: 0x21000021
> 2016-04-07 14:06:16,056 - INFO #
> 2016-04-07 14:06:16,056 - INFO # FSR/FAR:
> 2016-04-07 14:06:16,060 - INFO #  CFSR: 0x00008200
> 2016-04-07 14:06:16,060 - INFO #  HFSR: 0x40000000
> 2016-04-07 14:06:16,061 - INFO #  DFSR: 0x00000008
> 2016-04-07 14:06:16,061 - INFO #  AFSR: 0x00000000
> 2016-04-07 14:06:16,066 - INFO #  BFAR: 0xf134b7e4
> 2016-04-07 14:06:16,066 - INFO # Misc
> 2016-04-07 14:06:16,066 - INFO # EXC_RET: 0xfffffff1
> 2016-04-07 14:06:16,078 - INFO # Attempting to reconstruct state for
> debugging...
> 2016-04-07 14:06:16,078 - INFO # In GDB:
> 2016-04-07 14:06:16,078 - INFO #   set $pc=0x8000fe4
> 2016-04-07 14:06:16,079 - INFO #   frame 0
> 2016-04-07 14:06:16,079 - INFO #   bt
> 2016-04-07 14:06:16,079 - INFO #
> 2016-04-07 14:06:16,079 - INFO # ISR stack overflowed by at least 48 bytes.
>
> When I remove this line ( printf("%.2" PRIu32 "\n", last_wakeup -
> first_wakeup); )
> my program run without an error
>
>
> All the best
> Theodore
>
>
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20160407/e6c82f3e/attachment.html>


More information about the devel mailing list