- #1
haxor489
- 25
- 0
It's been a while since I've done some C programming and I can't remember how I should go about implementing this. I have a chunk of memory allocated for storing an array of data. The allocation takes place while the main program is running. The data is being stored to the already allocated memory space in an interrupt (this code is running on a microcontroller) . My issues is accessing the memory location of the latest empty position in the array, to add the next sequence of data. The interrupt is declared and defined in another .c file.
My , probably overly complicated, idea was to reserve two bytes at the beginning of the allocated memory space; one to act as an iterator for the array and the other as a tail pointer. I'd use the tail pointer in the interrupt to place the received data into the array and increment the pointer for the next interrupt.
I feel like there's probably an easier way to go about this. Thoughts or suggestions?
My , probably overly complicated, idea was to reserve two bytes at the beginning of the allocated memory space; one to act as an iterator for the array and the other as a tail pointer. I'd use the tail pointer in the interrupt to place the received data into the array and increment the pointer for the next interrupt.
I feel like there's probably an easier way to go about this. Thoughts or suggestions?