Hi all!
I'm trying to take advantage of the RAM on the Teensy 4.1 to have a little memory buffer that we can use for diagnostics when errors occur in my system. The memory buffer is just a CircularBuffer (using the arduino library) that is filled with CAN_message_t data types from the FlexCAN_T4 library.
I'm using the following code to declare and initialize the data_buffer in RAM2:
This seems to work. When I build the code, it shows that the RAM2 space is now being used:
This being said, I would still like to validate that the data buffer is being stored as intended in RAM2 during runtime and I would like to include this check in my test suite? Is there a way to check this?
I'm trying to take advantage of the RAM on the Teensy 4.1 to have a little memory buffer that we can use for diagnostics when errors occur in my system. The memory buffer is just a CircularBuffer (using the arduino library) that is filled with CAN_message_t data types from the FlexCAN_T4 library.
I'm using the following code to declare and initialize the data_buffer in RAM2:
Code:
/**
* Declare location in memory that is the size of the CircularBuffer that will store the
* CAN messages and then declare the data_buffer without initializing it so it is global
*/
DMAMEM uint8_t buffer_storage[sizeof(CircularBuffer<CAN_message_t, BUFFER_SIZE>)];
CircularBuffer<CAN_message_t, BUFFER_SIZE> *data_buffer;
/**
* Initializes the data_buffer in the allocated memory set aside for the buffer using the
* new (address) syntax for creating the object
*/
void setup_buffer() {
data_buffer = new (buffer_storage) CircularBuffer<CAN_message_t, BUFFER_SIZE>();
}
This seems to work. When I build the code, it shows that the RAM2 space is now being used:
Code:
teensy_size: Memory Usage on Teensy 4.1:
teensy_size: FLASH: code:99568, data:9728, headers:8460 free for files:8008708
teensy_size: RAM1: variables:25056, code:93640, padding:4664 free for local variables:400928
teensy_size: RAM2: variables:372448 free for malloc/new:151840
This being said, I would still like to validate that the data buffer is being stored as intended in RAM2 during runtime and I would like to include this check in my test suite? Is there a way to check this?