STM32H723 MDAM not getting OCTOSPI1 request
Hi,
I'm trying to use MDMA to send some data over OCTOSPI1 in indirect mode but so far I haven't been successful. Here is my OCTOSPI1 initialization code:
// ---- OCTOSPI1 peripheral ----
RCC->AHB3ENR |= RCC_AHB3ENR_OSPI1EN;
OCTOSPI1->DCR1 = 0x0000;
OCTOSPI1->DCR1 |= (0xFFFA << OCTOSPI_DCR1_DEVSIZE_Pos);
OCTOSPI1->DCR2 = 0x0000;
OCTOSPI1->DCR2 |= (0x4 << OCTOSPI_DCR2_PRESCALER_Pos); // Divide AHB clock by 5
OCTOSPI1->DLR = 0x0000;
OCTOSPI1->DLR |= N_BYTES - 1; // 40 bytes
OCTOSPI1->CCR = 0x0000;
OCTOSPI1->CCR |= (0x4 << OCTOSPI_CCR_DMODE_Pos); // Just data, no address, no instruction, no alternate bytes
OCTOSPI1->CR = 0x0000;
OCTOSPI1->CR |= (0x7 << OCTOSPI_CR_FTHRES_Pos) | // FTF is set when space is at least 8 bytes
OCTOSPI_CR_DMAEN;
And here is my MDMA initialization:
// ---- DMA ----
RCC->AHB3ENR |= RCC_AHB3ENR_MDMAEN;
MDMA_Channel0->CCR &= ~MDMA_CCR_EN;
MDMA_Channel0->CCR = 0x0000;
MDMA_Channel0->CCR |= (0x3 << MDMA_CCR_PL_Pos);
MDMA_Channel0->CTCR = 0x0000;
MDMA_Channel0->CTCR |= (0x0 << MDMA_CTCR_SSIZE_Pos) |
(0x0 << MDMA_CTCR_DSIZE_Pos) |
// MDMA_CTCR_SWRM |
(0x7 << MDMA_CTCR_TLEN_Pos); // Transmit 8 bytes
MDMA_Channel0->CSAR = (uint32_t) pData;
MDMA_Channel0->CDAR = (uint32_t)&(OCTOSPI1->DR);
MDMA_Channel0->CTBR |= (MDMA_REQUEST_OCTOSPI1_FIFO_TH << MDMA_CTBR_TSEL_Pos); // mdmda_str22: OCTOSPI1 FIFO threshold
MDMA_Channel0->CIFCR = 0xFFFFFFFF;
MDMA_Channel0->CCR |= MDMA_CCR_EN;
After this, I enable OCTOSPI1 and the FTF flag gets set, but nothing happens with the MDMA peripheral. I'm checking its register in debug mode but I see no changes after enabling OCTOSPI1. I'm not sure if the MDMA request is being generated by OCTOSPI1 or received by MDMA.
The OCTOSPI1 peripheral sends data without issue if I manually write to the DR register.
Is there anything I'm missing in the initialization code above?
Thanks