This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF51822 64 bitwise arithmetic

Hello. I need to hold 64-bit timer value. I store the 32-bit hardware timer value in one variable (low DWORD) and use an additional uint32_t variable as a an upper part of 64-bit timer value (high DWORD).

So, I have a 64-bit unsigned integer stored in 2 32-bit consecutive variables. All works ok, but it is inconvenient to use this construction in calculations (adding, sub and so on).


The questions:

  1. is nRF51822 supports 64 bit arithmetic?

  2. I obtained a strange result when try to use unsigned long long - program is compiled and simple operations (add, sub) is seems to ok, but when I try it in comlex application - it's fault.

  3. If nRF51822 don't support a native 64 bit arithmetic, can you recomend some C library to emulate working with those long numbers.


I use a gcc ARM compliler. Chip revision: nRF51822 QFAAG0.

Thanks.

Parents
  • Use uint64_t after including <inttypes.h>. If you're formatting it for output, use %llu or PRIu64 or similar macros. long long formatting is not available when using newlib nano.

    Be aware that getting an accurate 64-bit timer value taking into account overflow can be tricky, and some details differ depending on whether you're reading from a HFCLK-synchronous TIMER or an LFCLK-synchronous RTC.

Reply
  • Use uint64_t after including <inttypes.h>. If you're formatting it for output, use %llu or PRIu64 or similar macros. long long formatting is not available when using newlib nano.

    Be aware that getting an accurate 64-bit timer value taking into account overflow can be tricky, and some details differ depending on whether you're reading from a HFCLK-synchronous TIMER or an LFCLK-synchronous RTC.

Children
No Data
Related