Skip to main content
Apill
Associate III
November 1, 2018
Question

ARM Cortex M4., How can i know how many bytes a variable is taking to store the value?

  • November 1, 2018
  • 4 replies
  • 1677 views

Hi I have configured my ADC as Input 10 bit and i would like to sample the signal from accelerometer at 20KHz. I would like to know how much of address space is the memory taking to store these? Is the memory taking 1 byte, 2 byte, 4 byte ? How can I know that in Keil/ Data sheet ?

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
November 1, 2018

Depends on the definition of the variable, C use sizeof() to determine the size in bytes of a variable, structure, array, etc.

uint16_t takes 2 bytes

uint32_t takes 4 bytes

Some fairly basic data representation stuff...

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
November 1, 2018

10-bits here could minimally use 2 bytes when stored as a 16-bit value

uint16_t array[200]; // 400 bytes

uint8_t array[1024]; // 1024 bytes

uint32_t arrary[1024]; // 4096 bytes

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Apill
ApillAuthor
Associate III
November 2, 2018

if i am using a 10 bit data from sensor, can it be stored in the format of uint8_t array ? If yes, how does the memory foot print work in this case ? will it be stored in two 8 bit addressing formats ?