2019-06-15 10:11 AM
To exchange data with my display I am using the i2c protocol. I decided to exchange data with the DMA but I have problems. Without DMA everything works perfectly. Communication does not go well with Dma. The configuration is the default, and the only difference in the code is the name of the 'transmit' and 'receive' ending with DMA. What can the problem be due to? I'm going crazy
Configuration DMA
/* I2C1_TX Init */
hdma_i2c1_tx.Instance = DMA1_Stream6;
hdma_i2c1_tx.Init.Channel = DMA_CHANNEL_1;
hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_i2c1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_i2c1_tx) != HAL_OK)
{
Error_Handler();
}
I attach the library I use to communicate with the display .. very simple
2019-06-15 10:26 AM
Well mostly use SPI which bit rate calls for DMA the most.
When using HAL DMA, make sure you get the proper I2C callback (don't use DMA callbacks directly).
Was told : Read carefully HAL comments on top of H and C file.
Or check out if there is a Nucleo I2C+DMA example to get started.
2019-06-15 10:40 AM
I study from a book and I followed what he told me ... I don't understand where I'm wrong.