AnsweredAssumed Answered

In FLEXSPI_TransferHandleIRQ(), FLEXSPI_WriteBlocking(), and FLEXSPI_ReadBlocking() input/output from/to RFDR/TFDR is 1 word more than caller specifies in 'size' parameter in some cases

Question asked by Stephen Schwartz-Fenwick on Jul 16, 2018
Latest reply on Jul 18, 2018 by Kerry Zhou

In FLEXSPI_TransferHandleIRQ(), FLEXSPI_WriteBlocking(), and FLEXSPI_ReadBlocking() input/output from/to RFDR/TFDR is  1 word more than caller specifies in 'size' parameter in certain cases

 

In attached image, you can see how 'size' parameter, which specifies transfer size in bytes is divided by 4 then increased by 1.

 

So if caller specifies:

 

a) Write 2 bytes : 1 word is copied into caller's buffer (Ok, as long as caller allocates in word multiples)

b) Write 3 bytes : 1 word is copied into caller's buffer (Ok, as long as caller allocates in word multiples)

c) Write 4 bytes : 2 words are copied into caller's buffer! (Buffer overflow!)

d) Write 5 bytes : 2 words are copied into caller's buffer! (Ok, as long as caller allocates in word multiples)

 

Does anyone know why this code does not account for case (c)? 

Attachments

Outcomes