AnsweredAssumed Answered

STM32F7 code samples for SPI and DCMI in DMA Circular mode with small reward

Question asked by karpavicius.linas on Aug 20, 2015
Latest reply on Nov 9, 2015 by gonzalez.laurent
!!!!! WARNING, if someone help me with both problems, you will get one STM32F429 in LQFP144, 3x STM32F746 in LQFP144, and two STM32L4 in LQFP100 as acknowledgmentof help provided, free shipping !!!!!

So i am a bit tired to porting SPI and DCMI code to work , i clearly don't understand hardware and software, but i know for some one who work with HAL library, it will be 30min work ( a least it was for me in SPI  and DCMI form zero)

So all i need is code for STM32F7, that will will do same as for STM32F429.

So this is SPI DMA in circular mode for STM32F429:
#define SPIx                           SPI2
#define SPIx_CLK                       RCC_APB1Periph_SPI2
#define SPIx_CLK_INIT                  RCC_APB1PeriphClockCmd
#define SPIx_IRQn                      SPI2_IRQn
#define SPIx_IRQHANDLER                SPI2_IRQHandler
 
#define SPIx_SCK_PIN                   GPIO_Pin_10
#define SPIx_SCK_GPIO_PORT             GPIOB
#define SPIx_SCK_GPIO_CLK              RCC_AHB1Periph_GPIOB
#define SPIx_SCK_SOURCE                GPIO_PinSource10
#define SPIx_SCK_AF                    GPIO_AF_SPI2
 
#define SPIx_MISO_PIN                  GPIO_Pin_2
#define SPIx_MISO_GPIO_PORT            GPIOC
#define SPIx_MISO_GPIO_CLK             RCC_AHB1Periph_GPIOC
#define SPIx_MISO_SOURCE               GPIO_PinSource2
#define SPIx_MISO_AF                   GPIO_AF_SPI2
 
#define SPIx_MOSI_PIN                  GPIO_Pin_3
#define SPIx_MOSI_GPIO_PORT            GPIOC
#define SPIx_MOSI_GPIO_CLK             RCC_AHB1Periph_GPIOC
#define SPIx_MOSI_SOURCE               GPIO_PinSource3
#define SPIx_MOSI_AF                   GPIO_AF_SPI2
 
#define SPIx_DMA                       DMA1
#define SPIx_DMA_CLK                   RCC_AHB1Periph_DMA1
 
#define SPIx_TX_DMA_CHANNEL            DMA_Channel_0
#define SPIx_TX_DMA_STREAM             DMA1_Stream4
 
#define SPIx_RX_DMA_CHANNEL            DMA_Channel_0
#define SPIx_RX_DMA_STREAM             DMA1_Stream3
 
#define DMA_STREAM               DMA1_Stream3
#define DMA_CHANNEL              DMA_Channel_0
#define DMA_STREAM_CLOCK         RCC_AHB1Periph_DMA1
#define DMA_STREAM_IRQ           DMA1_Stream3_IRQn
 
#define BUFFERSIZE                      54310
 
extern uint8_t DataRx[BUFFERSIZE];
extern uint8_t DataTx[BUFFERSIZE];
extern uint32_t LINE;
void SPI_Config(void)
{
  GPIO_InitTypeDef      GPIO_InitStructure;
  DMA_InitTypeDef       DMA_InitStructure;
  SPI_InitTypeDef       SPI_InitStructure;
  SPIx_CLK_INIT(SPIx_CLK, ENABLE);
   
  /* Enable GPIO clocks */
  RCC_AHB1PeriphClockCmd(SPIx_SCK_GPIO_CLK | SPIx_MISO_GPIO_CLK | SPIx_MOSI_GPIO_CLK, ENABLE);
   
  /* Enable DMA clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE);
 
  /* Connect SPI pins to AF5 */ 
  GPIO_PinAFConfig(SPIx_SCK_GPIO_PORT,  SPIx_SCK_SOURCE,  SPIx_SCK_AF );
  GPIO_PinAFConfig(SPIx_MISO_GPIO_PORT, SPIx_MISO_SOURCE, SPIx_MISO_AF);   
  GPIO_PinAFConfig(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_SOURCE, SPIx_MOSI_AF);
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;
 
  /* SPI SCK pin configuration */
  GPIO_InitStructure.GPIO_Pin = SPIx_SCK_PIN;
  GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStructure);
   
  /* SPI  MISO pin configuration */
  GPIO_InitStructure.GPIO_Pin =  SPIx_MISO_PIN;
  GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStructure); 
 
  /* SPI  MOSI pin configuration */
  GPIO_InitStructure.GPIO_Pin =  SPIx_MOSI_PIN;
  GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStructure);
  
  SPI_I2S_DeInit(SPIx);
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
   
  /* DMA configuration -------------------------------------------------------*/
  /* Deinitialize DMA Streams */
  DMA_DeInit(SPIx_TX_DMA_STREAM);
  DMA_DeInit(SPIx_RX_DMA_STREAM);
   
  /* Configure DMA Initialization Structure */
  DMA_InitStructure.DMA_BufferSize = BUFFERSIZE ;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable ;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull ;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single ;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_PeripheralBaseAddr =(uint32_t) (&(SPIx->DR)) ;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
  /* Configure TX DMA */
  DMA_InitStructure.DMA_Channel = SPIx_TX_DMA_CHANNEL ;
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral ;
  DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)DataTx ;
  DMA_Init(SPIx_TX_DMA_STREAM, &DMA_InitStructure);
  /* Configure RX DMA */
  DMA_InitStructure.DMA_Channel = SPIx_RX_DMA_CHANNEL ;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory ;
  DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)DataRx ;
  DMA_Init(SPIx_RX_DMA_STREAM, &DMA_InitStructure);
   
  SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;
  SPI_Init(SPIx, &SPI_InitStructure);
 
  /* Enable DMA SPI TX Stream */
  DMA_Cmd(SPIx_TX_DMA_STREAM,ENABLE);
 
  /* Enable DMA SPI RX Stream */
  DMA_Cmd(SPIx_RX_DMA_STREAM,ENABLE); 
   
  /* Enable SPI DMA TX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, ENABLE);
 
  /* Enable SPI DMA RX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, ENABLE);
 
  /* Enable the SPI peripheral */
  SPI_Cmd(SPIx, ENABLE);
   
}
 
void EXTI_Int(void)
{
  EXTI_InitTypeDef   EXTI_InitStructure;
  GPIO_InitTypeDef   GPIO_InitStructure;
  NVIC_InitTypeDef   NVIC_InitStructure;
 
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
   
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
 
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource12);
 
  EXTI_InitStructure.EXTI_Line = EXTI_Line12;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
 
  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x10;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
   
}
 
extern uint32_t program_counter;
void EXTI15_10_IRQHandler(void)
{
 
  if(EXTI_GetITStatus(EXTI_Line12) != RESET)
  {
    SPI_Config();
    program_counter = 0;
    GPIOA->BSRRH=GPIO_Pin_2; // Make SPI in Sync with piezodriver DMA buffer pointer
    Delay(0xFFF);
    GPIOA->BSRRL=GPIO_Pin_2;
    EXTI_ClearITPendingBit(EXTI_Line12);
  }
}

And this is what i write for STM32F7, but it does not work. DMA looks like supplying data, but it is nonsensical: (IRQ on E12 pin should config DMA controller, IRQ works)

extern uint8_t DataRx[];
extern uint8_t DataTx[];
 
DMA_HandleTypeDef hdma_spi2_rx;
DMA_HandleTypeDef hdma_spi2_tx;
SPI_HandleTypeDef hspi2;
 
void SPI_Config(void)
{
 
  GPIO_InitTypeDef GPIO_InitStruct;
   
  __GPIOC_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();
  __SPI2_CLK_ENABLE();
   
  GPIO_InitStruct.Pin = GPIO_PIN_10;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
   
  GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
  hspi2.Instance = SPI2;
  hspi2.Init.Mode = SPI_MODE_SLAVE;
  hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi2.Init.NSS = SPI_NSS_SOFT;
  hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLED;
  hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
  hspi2.Init.CRCPolynomial = 7;
  hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
  hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLED;
  HAL_SPI_Init(&hspi2);
   
  __HAL_RCC_DMA1_CLK_ENABLE();
   
  HAL_DMA_DeInit(&hdma_spi2_tx);
  HAL_DMA_DeInit(&hdma_spi2_rx);
 
  HAL_NVIC_DisableIRQ(DMA1_Stream3_IRQn);
  HAL_NVIC_DisableIRQ(DMA1_Stream4_IRQn);
 
  hdma_spi2_rx.Instance = DMA1_Stream3;
  hdma_spi2_rx.Init.Channel = DMA_CHANNEL_0;
  hdma_spi2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
  hdma_spi2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
  hdma_spi2_rx.Init.MemInc = DMA_MINC_ENABLE;
  hdma_spi2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  hdma_spi2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  hdma_spi2_rx.Init.Mode = DMA_CIRCULAR;
  hdma_spi2_rx.Init.Priority = DMA_PRIORITY_HIGH;
  hdma_spi2_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
  hdma_spi2_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
  hdma_spi2_rx.Init.MemBurst = DMA_MBURST_SINGLE;
  hdma_spi2_rx.Init.PeriphBurst = DMA_PBURST_SINGLE;
  HAL_DMA_Init(&hdma_spi2_rx);
  
   
  __HAL_LINKDMA(&hspi2,hdmarx,hdma_spi2_rx);
 
 
  hdma_spi2_tx.Instance = DMA1_Stream4;
  hdma_spi2_tx.Init.Channel = DMA_CHANNEL_0;
  hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
  hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
  hdma_spi2_tx.Init.MemInc = DMA_MINC_ENABLE;
  hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  hdma_spi2_tx.Init.Mode = DMA_CIRCULAR;
  hdma_spi2_tx.Init.Priority = DMA_PRIORITY_HIGH;
  hdma_spi2_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
  hdma_spi2_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
  hdma_spi2_tx.Init.MemBurst = DMA_MBURST_SINGLE;
  hdma_spi2_tx.Init.PeriphBurst = DMA_PBURST_SINGLE;
  HAL_DMA_Init(&hdma_spi2_tx);
   
  __HAL_LINKDMA(&hspi2,hdmatx,hdma_spi2_tx);
   
  HAL_NVIC_SetPriority(DMA1_Stream3_IRQn,1,1);
  HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
  HAL_NVIC_SetPriority(DMA1_Stream4_IRQn,1,0);
  HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
 
 
  HAL_DMA_Start(&hdma_spi2_rx,(uint32_t)(&(SPI2->DR)),(uint32_t)(&DataRx), BUFFERSIZE);
  HAL_DMA_Start(&hdma_spi2_tx,(uint32_t)&DataTx,     (uint32_t)(&SPI2->DR),BUFFERSIZE);
   
  SPI2->CR2 |= 0x0002;
  SPI2->CR2 |= 0x0001;
  SPI2->CR1 |= SPI_CR1_SPE;
   
}
uint32_t spi_i = 0;
 
void SPIx_DMA_RX_IRQHandler(void)
{
  HAL_DMA_IRQHandler(hspi2.hdmarx);
}
 
 
void SPIx_DMA_TX_IRQHandler(void)
{
  HAL_DMA_IRQHandler(hspi2.hdmatx);
}
 
void EXTI_Int(void)
{
 
  GPIO_InitTypeDef   GPIO_InitStructure;
 
  __HAL_RCC_GPIOE_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
   
  GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  GPIO_InitStructure.Pin = GPIO_PIN_12;
  HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);
   
  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  GPIO_InitStructure.Pin = GPIO_PIN_0;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
 
  HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0, GPIO_PIN_RESET);
  Delay(0xFFFF);
  HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0, GPIO_PIN_SET);
   
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 1, 10);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
   
 
}
 
 
extern uint32_t program_counter;
void EXTI15_10_IRQHandler(void)
{
  if((EXTI->PR&0x01000)==0x01000)
  {
    spi_i++;
    SPI_Config();
    program_counter = 0;
    HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2, GPIO_PIN_SET);
    Delay(0xFFF);
    HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2, GPIO_PIN_RESET);
    EXTI->PR = 0x01000;
 }
}



And same problem with DCMI, i am hanging inside DMA2_Stream1_IRQHandler, but with STM32F429, i don't have to service any DMA2_Stream1 irq, so don't know what is happening here: (This code works flawlesly on STM32F429)

extern DMA_InitTypeDef        DMA_InitStructure;
 
 
void VITA1300_Init(void)
{
  DCMI_HW_Init(); //GPIO AF config
 
  DCMI_InitTypeDef DCMI_InitStructure;
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE);
  DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous;
  DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;
  DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling;
  DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_Low;
  DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low;
  DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;
  DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;
   
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
  DMA_DeInit(DMA2_Stream7);
  DMA_InitStructure.DMA_Channel = DMA_Channel_1;
  DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; 
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)SRAM_BANK_ADDR;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
  DMA_InitStructure.DMA_BufferSize = 1280;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst =DMA_PeripheralBurst_Single;
  DCMI_DeInit();
  DCMI_Init(&DCMI_InitStructure);
  DMA_Init(DMA2_Stream7, &DMA_InitStructure);
  DMA_Cmd(DMA2_Stream7,ENABLE);
  DCMI_Cmd(ENABLE);
  /*
  NVIC_InitTypeDef NVIC_InitStructure;
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  DCMI_ITConfig(DCMI_IT_LINE, ENABLE);
*/
  DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)(0x6C000000);
  DMA_Init(DMA2_Stream7, &DMA_InitStructure);
  DMA_Cmd(DMA2_Stream7,ENABLE);
  GPIO_ResetBits(GPIOB, GPIO_Pin_0);
  Delay(0xFFFF);
  GPIO_SetBits(GPIOB, GPIO_Pin_0);
  GPIO_SetBits(GPIOB, GPIO_Pin_6);      //FRAM_CS
  GPIO_SetBits(GPIOA, GPIO_Pin_12);     //DCMI_CS
   
  GPIO_SetBits(GPIOC, GPIO_Pin_10); // RESET_CAMERA
  Delay(0xFFFF);
  GPIO_ResetBits(GPIOC, GPIO_Pin_10);
  Delay(0xFFFF);
  GPIO_SetBits(GPIOC, GPIO_Pin_10);
  Delay(0xFFFF);
}
 
void DCMI_IRQHandler(void)
{
  if(DCMI_GetFlagStatus(DCMI_FLAG_LINERI) == SET)
  {
    register uint32_t address ;
    DMA_DeInit_DCMI_SHORT(DMA2_Stream1);
    address = LINE*binning_addr;
    DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)((SRAM_BANK_ADDR+address));
    DMA_Init_DCMI_SHORT(DMA2_Stream1, &DMA_InitStructure);
    DMA2_Stream1->CR |= (uint32_t)DMA_SxCR_EN;
    LINE++;
    DCMI->ICR = DCMI_FLAG_LINERI;
  }
 
void EXTI4_IRQHandler(void)
{
  if ((EXTI->PR & EXTI_Line4) != (uint32_t)RESET)
  {
    GPIOB->BSRRL = 2;
    DMA2_Stream1->CR &= ~DMA_SxCR_EN;
    DMA2_Stream1->CR  = 0;
    DMA2->LIFCR = 0x00000F40;
    DMA2_Stream1->CR = 0x02031400;
    DMA2_Stream1->FCR  = 0x21;
    DMA2_Stream1->M0AR = ((SRAM_BANK_ADDR+(LINE*binning_addr)));
    DMA2_Stream1->CR |= DMA_SxCR_EN;
    LINE++;
    EXTI->PR = EXTI_Line4;
    GPIOB->BSRRH = 2;
  }
}


and here is code for STM32F7, that is hanging inside stream irq...
void VITA1300_Init(void)
{
   
  GPIO_InitTypeDef GPIO_InitStruct;
  __GPIOA_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();
  __GPIOC_CLK_ENABLE();
  __GPIOD_CLK_ENABLE();
  __GPIOE_CLK_ENABLE();
  __GPIOF_CLK_ENABLE();
  __GPIOG_CLK_ENABLE();
  __HAL_RCC_DMA2_CLK_ENABLE();
  GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
   
  GPIO_InitStruct.Pin = GPIO_PIN_2;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
   
 
   
    /**DCMI GPIO Configuration   
    PE4     ------> DCMI_D4
    PA4     ------> DCMI_HSYNC
    PA6     ------> DCMI_PIXCLK
    PA9     ------> DCMI_D0
    PA10     ------> DCMI_D1
    PD3     ------> DCMI_D5
    PG10     ------> DCMI_D2
    PG11     ------> DCMI_D3
    PB7     ------> DCMI_VSYNC
    PB8     ------> DCMI_D6
    PB9     ------> DCMI_D7
    */
    GPIO_InitStruct.Pin = GPIO_PIN_4;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_9|GPIO_PIN_10;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_3;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
     
    hdcmi.Instance = DCMI;
    hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
    hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;
    hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;
    hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
    hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
    hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
    hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
    hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
    hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
    hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
    hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
    HAL_DCMI_Init(&hdcmi);
   
   __DCMI_CLK_ENABLE();
 
    /* Peripheral DMA init*/
   
    hdma_dcmi.Instance = DMA2_Stream1;
    hdma_dcmi.Init.Channel = DMA_CHANNEL_1;
    hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
    hdma_dcmi.Init.PeriphInc = DMA_PINC_ENABLE;
    hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
    hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
    hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_dcmi.Init.Mode = DMA_CIRCULAR;
    hdma_dcmi.Init.Priority = DMA_PRIORITY_VERY_HIGH;
    hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
    hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
    hdma_dcmi.Init.MemBurst = DMA_MBURST_SINGLE;
    hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;
    HAL_DMA_Init(&hdma_dcmi);
 
    __HAL_LINKDMA(&hdcmi,DMA_Handle,hdma_dcmi);
     
    DCMI->IER |= DCMI_IER_LINE_IE;
 
  /* Peripheral interrupt init*/
  HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0);
  HAL_NVIC_EnableIRQ(DCMI_IRQn); 
   
 
  //HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0);
  //HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
   
     
    __HAL_DCMI_ENABLE(&hdma_dcmi);
  /* Enable the DMA */
    __HAL_DMA_ENABLE(hdcmi.DMA_Handle);
     
    HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS,  ((uint32_t)0x6C000000), (uint32_t)1280); 
   
    DCMI_SPI_Config();
}
uint32_t dcmi = 0;
void DMA2_Stream1_IRQHandler(void)
{
  dcmi++;
}
 
//i need code for LINE IRQ, , just like with STM32F429, i did that on simple IRQ, and DCMI_LI IRQ, both working without any glitch.



Outcomes