2020-02-04 02:05 AM
// SPI_HandleTypeDef *hspi
// DMA_HandleTypeDef *hdmatx
hspi->Init.DataSize = SPI_DATASIZE_16BIT;
hdmatx->Init.MemInc = DMA_MINC_DISABLE;
hdmatx->Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdmatx->Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
while( hspi->State != HAL_SPI_STATE_READY );
HAL_DMA_DeInit(hdmatx);
HAL_DMA_Init(hdmatx);
HAL_SPI_DeInit(hspi);
HAL_SPI_Init(hspi);
Solved! Go to Solution.
2020-02-04 10:59 AM
Read out and compare/post content of both SPI and DMA registers, before and after the change.
JW
2020-02-04 03:42 AM
>DMA settings do not seem to be updated
How do you know? Did you read out content of DMA registers before and b after and compared them and checked against the expected content?
JW
2020-02-04 04:42 AM
When I checked the TX data by logic analyzer, it changed as follows.
data: [0x00,0xF8,0x00,0xF8,...]
// SPI_DATASIZE_8BIT, DMA_MDATAALIGN_BYTE, DMA_PDATAALIGN_BYTE, DMA_MINC_ENABLE
... 00 F8 00 F8 00 F8 00 F8 ...
// SPI_DATASIZE_16BIT, DMA_MDATAALIGN_HALFWORD, DMA_PDATAALIGN_HALFWORD, DMA_MINC_ENABLE
... 00 F8 F8 00 F8 F8 00 F8 ...
2020-02-04 10:59 AM
Read out and compare/post content of both SPI and DMA registers, before and after the change.
JW
2020-02-04 09:12 PM
Following your advice, I checked the DMA registers and found that they were not set to the intended values. After the HAL_SPI_Init () function, the contents of hspi-> hdmatx were rewritten. Changing the order of the code worked fine. Thanks for the advice.