cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating Flash data CRC using DMA

Dilip_Kumar
Associate

I am currently working on calculating the FLASH CRC through DMA on the NUCLEO-H755ZI-Q development board. I've successfully read from flash and calculated the CRC using DMA in memory-to-memory.

Now, I'm facing challenges while configuring DMA for DMA_MEMORY_TO_PERIPH. I attempted to read directly from flash into the CRC register using the following call:

" HAL_DMA_Start(&hdma_dma_generator0, (uint32_t)flash_start_addr, (uint32_t)&CRC->DR, FLASH_BUFFER_SIZE); "
Is it feasible to calculate the CRC using DMA_MEMORY_TO_PERIPH? I would appreciate any suggestions or insights you might have!

Here are my current DMA configurations:
hdma_dma_generator0.Instance = DMA1_Stream0;
hdma_dma_generator0.Init.Request = DMA_REQUEST_GENERATOR0;
hdma_dma_generator0.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_dma_generator0.Init.PeriphInc = DMA_PINC_ENABLE;
hdma_dma_generator0.Init.MemInc = DMA_MINC_ENABLE;
hdma_dma_generator0.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_dma_generator0.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_dma_generator0.Init.Mode = DMA_NORMAL;
hdma_dma_generator0.Init.Priority = DMA_PRIORITY_HIGH;
hdma_dma_generator0.Init.FIFOMode = DMA_FIFOMODE_DISABLE;


Thank you for your help!

2 REPLIES 2

Use "memory to memory".

Don't let the "peripheral" and/or "memory" confuse you, it is (mostly) not about physical memory or peripheral, but about the way how DMA is triggered. In M2M transfers, DMA is triggered automatically by DMA itself and performs all transfers at once. Other transfers require some peripheral to trigger them.

JW

Saket_Om
ST Employee

Hello @Dilip_Kumar 

the Peripheral Increment Mode should be set to DMA_PINC_DISABLE to keep the peripheral address constant. Additionally, you need to ensure that the data alignment settings match the requirements of the CRC peripheral.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar