This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52840 uint64_t problem

I have one problem with unsing uint64_t in application...

Im for test try simple demo:

uint64_t test = 1327644190303473294;
NRF_LOG_INFO("test: %"PRIX64"\n", test);

But I receive in RTT Viewer output:

 0> APP:INFO:test: 0

What Im doing wrong? Thanks for any help :)

Parents
  • Something still doesn't work ok:

    uint64_t test = 7340861779410949837;
    NRF_LOG_INFO("test: %llu\n", test);
    NRF_LOG_FLUSH();
    

    Produce:

     0> APP:INFO:test: 47549582942412
    

    I will check project settings...

    P.S. If I disable MicroLib I get:

    0> APP:INFO:test: 319297229
    

    This is if I convert uint64 to 2xuint32 by calculator on pc one of int32 ...

    If I change Optimization from Level 3 to Level 0 result is same...

  • No char array is also ok. Im also found that NRF_LOG_INFO doesn't work witn char array(strings) ... Example:

    uint32_t info_variant = NRF_FICR->INFO.VARIANT;
    
    unsigned char buffer[5];
    buffer[0] = info_variant >> 24;
    buffer[1] = info_variant >> 16;
    buffer[2] = info_variant >> 8;
    buffer[3] = info_variant;  
    buffer[4] = '\0';
    
    NRF_LOG_INFO("string: %s \n", buffer);
    SEGGER_RTT_printf(0, "string: %s \n", buffer);
    NRF_LOG_FLUSH();
    

    SEGGER_RTT_printf function print AAAA which is OK. But If I try use NRF_LOG_INFO building produce error.

Reply
  • No char array is also ok. Im also found that NRF_LOG_INFO doesn't work witn char array(strings) ... Example:

    uint32_t info_variant = NRF_FICR->INFO.VARIANT;
    
    unsigned char buffer[5];
    buffer[0] = info_variant >> 24;
    buffer[1] = info_variant >> 16;
    buffer[2] = info_variant >> 8;
    buffer[3] = info_variant;  
    buffer[4] = '\0';
    
    NRF_LOG_INFO("string: %s \n", buffer);
    SEGGER_RTT_printf(0, "string: %s \n", buffer);
    NRF_LOG_FLUSH();
    

    SEGGER_RTT_printf function print AAAA which is OK. But If I try use NRF_LOG_INFO building produce error.

Children
No Data
Related