cancel
Showing results for 
Search instead for 
Did you mean: 

SPI DMA Transmission Starting from wrong address

Giridhara_Datta_G
Associate III

Issue with SPI DMA Transmission Starting from Random Index Instead of Array Start (Circular Mode) (STM32L562VET6)

I am working with an STM32L562VET6 and have a 2D array DATA defined as follows:

 

uint8_t DATA[NOS][3] = {};

 

Here, NOS = 20000, and each row of this array contains a 24-bit integer value split into three bytes. For example:

 

DATA[3][0] = 0x00;  
DATA[3][1] = 0x00;  
DATA[3][2] = 0x03;  

 

 I’m transmitting this array using SPI with DMA in circular mode, like this:

 

HAL_SPI_Transmit_DMA(&hspi2, DATA, (uint16_t)(NOS * 3));

 

On the receiving side, I merge the three bytes back into a 24-bit integer. However, instead of the values starting from 0 (from DATA[0][0]), the transmission starts from some random index, goes up to 19999, and then wraps around to start again from 0 to the random starting index.

Why is the transmission not starting from DATA[0][0] in circular mode?
How can I ensure that the transmission always starts correctly from the beginning of the array?

Any insights or suggestions would be greatly appreciated! Thank you so much in advance!

1 REPLY 1
gbm
Lead III

And what's the code for the receiving party? How do you ensure the the reception starts in sync with transmit?

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice