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

SPIS example: print decimals

Hello,

I'm running the SPIS example from Keil (SDK 15.0), but I want to print out the received as the decimal value instead of as a string. If I change %s to a %d in this line:

NRF_LOG_INFO(" Transfer completed. Received: %s",(uint32_t)m_rx_buf);

the value printed is always "536870920", regardless of what data I send. I assume this is the address the pointer is pointing to. This works:

NRF_LOG_INFO(" Transfer completed. Received: %d", m_rx_buf[0]);

but I can only print it in 8 bit chunks, how do I print a 16-bit number? Or how can I merge two of the 8-bit array entries into one 16-bit variable?

Also, I will be sending this 16-bit number over BLE, can I send it directly or will I have to send it as two 8-bit values?

Thank you!

Parents Reply Children
No Data
Related