ARM Cortex M4., How can i know how many bytes a variable is taking to store the value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-01 1:53 PM
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 ?
- Labels:
-
ADC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-01 2:00 PM
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...
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-01 2:02 PM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 8:44 AM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 9:08 AM
The processor doesn't have a 10-bit format, it is held at a high precision level. The registers in the part are 32-bit, but it can also be handled as a 16-bit value
A uint16_t would be in two consecutive uint8_t memory locations, in the case of the Cortex part, in Little Endian format, so low order bits in the first byte, high order bits in the second.
An uint16_t array containing 1, 2, 3 would take six bytes in memory
01 00 02 00 03 00
This is Computer Studies 101 level stuff.
Up vote any posts that you find helpful, it shows what's working..
