cancel
Showing results for 
Search instead for 
Did you mean: 

trasfert data from DCMI to SRAM using DMA

sak hos
Associate III
Posted on May 06, 2017 at 16:24

Hello,

i'm using STM32F4Discovery with the OV7670 camera , i'm trying to get a QVGA picture (320*240) RGB (each pixel is coded in one byte) and then i'll try to send thses picture to a server using SIM900, the probleme is that when i set a breakpoint at the DMA2_ IRQhandler the breakpoint is never reached although the register TCIF1 is set , and that mean that trasfert is done.

i attached my code for more details

is there somone who could help me

thank you

############################################################################################

void DCMI_Configure(uint32_t *frame)

{

DCMI_InitTypeDef DCMI_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

DMA_InitTypeDef DMA_InitStructure;

DMA_InitTypeDef DMA_InitStructureusart;

NVIC_InitTypeDef NVIC_InitStructure;

NVIC_InitTypeDef NVIC_InitStructureDcmiToDma;

/* Enable DCMI GPIOs clocks */

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOE, ENABLE);

/* Enable DCMI clock */

RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE);

/* Connect DCMI pins to AF13 ************************************************/

GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI);//HSYNC

GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI);//PCLK

GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI);//VSYNC

//RED

GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_DCMI);//D0

GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_DCMI);//D1

GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_DCMI);//D2

//Blue

GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_DCMI);//D3

GPIO_PinAFConfig(GPIOE, GPIO_PinSource4, GPIO_AF_DCMI); //D4

GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI); //D5

GPIO_PinAFConfig(GPIOE, GPIO_PinSource5, GPIO_AF_DCMI);//D6

GPIO_PinAFConfig(GPIOE, GPIO_PinSource6, GPIO_AF_DCMI);//D7

/* DCMI GPIO configuration **************************************************/

/*

D0 -- PC6

D1 -- PA10

D2 -- PC8

D3 -- PC9

D4 -- PE4

D5 -- PB6

D6 -- PE5

D7 -- PE6

PCK - PA6

HS -- PA4

VS -- PB7

*/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_10 ;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_8 | GPIO_Pin_9;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_4;

GPIO_Init(GPIOE, &GPIO_InitStructure);

/* PCLK(PA6) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

GPIO_Init(GPIOA, &GPIO_InitStructure);

/* DCMI configuration *******************************************************/

DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_SnapShot;//DCMI_CaptureMode_Continuous;//DCMI_CaptureMode_SnapShot;

DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;

DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling;

DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High;

DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_High;

DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_1of4_Frame; //DCMI_CaptureRate_All_Frame;

DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;

DCMI_Init(&DCMI_InitStructure);

/* DCMI Interrupts config ***************************************************/

DCMI_ITConfig(DCMI_IT_VSYNC, ENABLE);

DCMI_ITConfig(DCMI_IT_LINE, ENABLE);

DCMI_ITConfig(DCMI_IT_FRAME, ENABLE);

DCMI_ITConfig(DCMI_IT_ERR, ENABLE);

/* Configures the DMA2 to transfer Data from DCMI to Memory ****************/

/* Enable DMA2 clock */

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);

/* DMA2 Stream1 Configuration */

DMA_DeInit(DMA2_Stream1);

DMA_InitStructure.DMA_Channel = DMA_Channel_1;

DMA_InitStructure.DMA_PeripheralBaseAddr =(uint32_t)(DCMI_BASE + 0x28);//(DCMI_BASE + 0x28);//DCMI->DR; //DCMI_DR_ADDRESS;//(uint32_t)(&DCMI->DR);

DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)frame;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

DMA_InitStructure.DMA_BufferSize = 19200;//25344*3;//320*240*2;//0xfffe; //= Image size /4 //0xfffe;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//DMA_MemoryInc_Disable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;

DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;// First take one picture//DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

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;

DMA_Init(DMA2_Stream1, &DMA_InitStructure);

DMA_ITConfig(DMA2_Stream1,DMA_IT_TC,ENABLE);

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

NVIC_InitStructureDcmiToDma.NVIC_IRQChannel = DMA2_Stream1_IRQn;

NVIC_InitStructureDcmiToDma.NVIC_IRQChannelPreemptionPriority = 2;//1

NVIC_InitStructureDcmiToDma.NVIC_IRQChannelSubPriority = 2;//1

NVIC_InitStructureDcmiToDma.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

#########################################################################################'

void DMA2_Stream1_IRQHandler(void)

{

//Test on DMA2 Channel1 Transfer Complete interrupt

if(DMA_GetITStatus(DMA2_Stream1,DMA_IT_TCIF1) == SET)

{

// USART_SendData(USART2, DMA2->);

DMA_ClearITPendingBit(DMA2_Stream1,DMA_IT_TCIF1);

}

if(DMA_GetITStatus(DMA2_Stream1,DMA_IT_TEIF1) == SET)

{

//USART_SendData(USART2, buff[0]);//TM_USB_VCP_Send(&buff[0], 255);

DMA_ClearITPendingBit(DMA2_Stream1,DMA_IT_TEIF1);

}

}
0 REPLIES 0