electroRF
Member
Hi,
Say that you need to write in microcontroller a function which needs to read values from an array - one value per call.
This function is called many times.
What would be faster implementation:
1. to write the array's values hard-coded to the memory? (which would be ROM, right?)
i.e. i assume it means setting a global array, which will include all the values.
--- does it mean it'd be stored in data segment of RAM?
2. just when main starts, use a loop (e.g. for loop) to compute all values in the array.
--- I assume that in that case the array will be global but will not be initialized.
I'd appreciate your comments.
Thank you.
Say that you need to write in microcontroller a function which needs to read values from an array - one value per call.
This function is called many times.
What would be faster implementation:
1. to write the array's values hard-coded to the memory? (which would be ROM, right?)
i.e. i assume it means setting a global array, which will include all the values.
--- does it mean it'd be stored in data segment of RAM?
2. just when main starts, use a loop (e.g. for loop) to compute all values in the array.
--- I assume that in that case the array will be global but will not be initialized.
I'd appreciate your comments.
Thank you.