Buffer Logic for Data Transmission
The Serial Communication Interface (SCI) buffer logic manages data transmission between a
host and target hardware using a global variable, dataOutput
, in a
Data Store Memory block. Use this approach to manage data from
communication blocks that exceed the FIFO size by temporarily storing incoming data in a
buffer and accessing it only when the buffer is full. For more information, see Serial Communication Using SCI Blocks.
The buffer logic for data transmission is demonstrated using the target model. To open a Simulink® target model from the MATLAB® command window, use the following command:
open_system('c28xSCIRxDataWithBuffer.slx');

Buffer Management
Incoming data is stored in a buffer until it reaches full capacity.
When the buffer is full, a GPIO pin toggles to indicate readiness, triggering an external interrupt.
The interrupt initiates data transmission and resets the GPIO signal.
Understand Buffer Implementation in MATLAB Function: dataBufferImpl
The buffer is defined as a global variable using the Data Store Memory block. The buffer handling logic is implemented in a MATLAB script, which is then invoked in Simulink using a MATLAB Function block. This function stores incoming data into the buffer and triggers a signal when the buffer is full.
Input
dataInput
: The data to be buffered.
Output
dataReady:
A flag indicating if the buffer is full.
Key Points
Buffer Size: Size of the buffer.
Buffer Initialization: Initialize a persistent buffer
(cachedDataOutput)
to store incoming data temporarily.Data Storage: Use the global variable
dataOutput
to copy the buffered data fromcachedDataOutput
once it is ready.C Function Integration: Call the external C function
copyDataIntoBuffer
during code generation to copy the input data into the buffer. The C function is used to handle memory operation efficiently using pointers.Buffer Full Signal: Set
dataReady
to1
when thecachedDataOutput
buffer is full, and copy the buffered data todataOutput
.
C Function: copyDataIntoBuffer
Copy the input data into the buffer according to its capacity.
Input
dataOutput
: Pointer to the buffer to store the data.dataInput
: Pointer to the incoming datadataInputSize
: The size of the incoming data.bufferSize
: The total buffer capacity.
Output
Return 1 if the buffer is full and data is ready; otherwise, return 0.