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
  • I use 64 bit fixed point on a nrf51822 quite heavily and haven't noticed any problems with gcc-arm-none-eabi-4_9-2014q4-20141203 from launchpad.net/gcc-arm-embedded

    I'm mostly doing 32 * 32 multiplies with a 64 bit result and then >> the result right away. But looking at the compiler output it is using __aeabi_lmul() which is 'long long' * 'long long' -> 'long long'.

    Can you provide a simple example that fails and I'll try it in my setup.

Reply
  • I use 64 bit fixed point on a nrf51822 quite heavily and haven't noticed any problems with gcc-arm-none-eabi-4_9-2014q4-20141203 from launchpad.net/gcc-arm-embedded

    I'm mostly doing 32 * 32 multiplies with a 64 bit result and then >> the result right away. But looking at the compiler output it is using __aeabi_lmul() which is 'long long' * 'long long' -> 'long long'.

    Can you provide a simple example that fails and I'll try it in my setup.

Children
  • Thank you for an answer. Sorry I cannot provide an example, because it's a huge application with a lot of code. When I try to use a simple test program only with 64 bit arithmetic (without my app) - all looks correct. But when I use it inside my app - trouble comes. I just want to know, that I am not missing something (in the datasheet or somewhere else) that state about NOT use a 64 bitwise. Now I know that it's completely possible. One question for you - how you declare a unsigned 64-bit wise? unsigned long long, uint64_t, QWORD (I know that it is near the same, but want to know). Thank you again.

Related