2024-10-19 01:26 PM - last edited on 2024-10-19 03:43 PM by SofLit
Hello,
i'm wondering if it is possible to copy data from RAM to flash using DMA after unlocking the FLASH memory
static const uint32_t src[4] ={80,20,30};
static uint32_t dst = 0x080E0000;
__HAL_RCC_DMA1_CLK_ENABLE();
dma_handler.Instance = DMA1_Stream0;
dma_handler.Init.Channel = DMA_CHANNEL_0;
dma_handler.Init.Direction = DMA_MEMORY_TO_MEMORY;
dma_handler.Init.PeriphInc = DMA_PINC_ENABLE;
dma_handler.Init.MemInc = DMA_MINC_ENABLE;
dma_handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
dma_handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
dma_handler.Init.Mode = DMA_NORMAL;
dma_handler.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&dma_handler);
//__HAL_LINKDMA(&flashHandle, hdma, dma_handler);
//HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13,GPIO_PIN_SET);
HAL_FLASH_Unlock();
FLASH_Erase_Sector(FLASH_SECTOR_11, VOLTAGE_RANGE_3);
HAL_DMA_Start(&dma_handler,(uint32_t)&src,(uint32_t)&dst,4);
HAL_FLASH_Lock();
Nothing is happened and the value still empty
Solved! Go to Solution.
2024-10-19 03:31 PM
Which STM32?
What exactly would be the point/value of doing it this way?
Do any of the functions return an error code?
The F2/F4 won't support memory-to-memory on DMA1
Wouldn't you need to enable the PG bit ?
2024-10-19 03:31 PM
Which STM32?
What exactly would be the point/value of doing it this way?
Do any of the functions return an error code?
The F2/F4 won't support memory-to-memory on DMA1
Wouldn't you need to enable the PG bit ?
2024-10-20 02:12 AM
Dear @abdelwahedbaha ,
as shared by @Tesla DeLorean . It has no meaning to write to flash via DMA , Flash writing as a specific controller and software sequence to strictly follow by activation of PG bit and polling for each correct Erase/Program and also Errors checking .
have a good start on STM32
STOne-32
2024-10-20 06:55 AM
Flash write access needs to be paced by the flash, not some other timing. As there is no such flash event to the DMA system, you can not do it. The reason why you want to do it is also unclear.