2014-07-22 10:02 AM
Hullo guys , I 'm trying to get my OV7670 cam working with STM32F207zg , and I have set up all required configurations , I want to get snapshot , transfer the frame to external SRAM , but the FRAME interrupt is never generated , while LINE interrupt is working fine , also the DMA flags r not set , HC/TC/ or even FIFO error , here is my code ,
// Enable the Clck of the DCMI module RCC_AHB2PeriphClockCmd (RCC_AHB2Periph_DCMI , ENABLE); // Reset the DCMI Registers RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_DCMI, ENABLE); RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_DCMI, DISABLE); // // Configure the DCMI DCMI_Struct.DCMI_CaptureMode=DCMI_CaptureMode_SnapShot; DCMI_Struct.DCMI_CaptureRate=DCMI_CaptureRate_All_Frame; DCMI_Struct.DCMI_ExtendedDataMode=DCMI_ExtendedDataMode_8b; DCMI_Struct.DCMI_HSPolarity=DCMI_HSPolarity_Low; DCMI_Struct.DCMI_PCKPolarity=DCMI_PCKPolarity_Rising; DCMI_Struct.DCMI_VSPolarity=DCMI_VSPolarity_High ; DCMI_Struct.DCMI_SynchroMode=DCMI_SynchroMode_Hardware; DCMI_Init(&DCMI_Struct); // Enable the DCMI Interrupts DCMI_ITConfig(DCMI_IT_VSYNC, ENABLE); DCMI_ITConfig(DCMI_IT_LINE, ENABLE); DCMI_ITConfig(DCMI_IT_FRAME, ENABLE); DCMI_ITConfig(DCMI_IT_ERR, ENABLE); // // // Enable the NVIC for the DCMI NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_DCMI.NVIC_IRQChannel=DCMI_IRQn; NVIC_DCMI.NVIC_IRQChannelCmd=ENABLE; NVIC_DCMI.NVIC_IRQChannelPreemptionPriority=1; NVIC_DCMI.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_DCMI); // // Enable NVIC for DMA2 , Stream 1 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_DCMI.NVIC_IRQChannel=DMA2_Stream1_IRQn; NVIC_DCMI.NVIC_IRQChannelCmd=ENABLE; NVIC_DCMI.NVIC_IRQChannelPreemptionPriority=0; NVIC_DCMI.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_DCMI); // // // Enable DMA2 Clock RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); // Configure the DMA DMA_DCMI.DMA_Channel = DMA_Channel_1; DMA_DCMI.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; // (0x50050028) DMA_DCMI.DMA_Memory0BaseAddr = 0x64000000; // Address of external SRAM DMA_DCMI.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_DCMI.DMA_BufferSize = 640*480*2/4; DMA_DCMI.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_DCMI.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_DCMI.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_DCMI.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_DCMI.DMA_Mode = DMA_Mode_Normal; DMA_DCMI.DMA_Priority = DMA_Priority_High; DMA_DCMI.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_DCMI.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_DCMI.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_DCMI.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream1, &DMA_DCMI); DMA_ITConfig(DMA2_Stream1 , DMA_IT_TC , ENABLE); DMA_ITConfig(DMA2_Stream1 , DMA_IT_FE , ENABLE); // Enable the Capture mode DCMI_Cmd(ENABLE); DCMI_CaptureCmd(ENABLE); DMA_Cmd(DMA2_Stream1, ENABLE); // // Any ideas ?2014-07-22 10:29 AM
Is the DMA faulting?
The DMA is only capable of doing 65535 transactions. Perhaps you have a sequencing issue?/* Enable DMA2 stream 1 and DCMI interface then start image capture */
DMA_Cmd(DMA2_Stream1, ENABLE);
DCMI_Cmd(ENABLE);
/* Insert 100ms delay: wait 100ms */
Delay(200);
DCMI_CaptureCmd(ENABLE);
2014-07-22 10:44 AM
Thx for ur reply Clive , well its less than 65535 transactions (640*480*2/4) / (4-word transaction) , and the DAM is not generating any fault , like i said above not even generating anything , i tried the delay , but its not working still .
2014-07-22 01:19 PM
(640*480*2/4) = 153600
DMA_BufferSize is a count, not a size in bytes If you get no DMA operations, it's kind of indicative there isn't a clock somewhere. You should look at all the interface clocks, and perhaps put the bus on an analyzer.2014-07-22 04:39 PM
all clocks r working clive , i can write to the various peripherals , well i could see that im kinda getting an image to the memory (due to the correlation between the pixels values in the external SRAM) .
When i use the continuous mode of the DCMI , and change the DMA to circular mode , all i get is just noise on the LCD (of course the Memory address was changed to the LCD address , also memory and peripheral increment are disabled) . I hope the Silicon is ok , cuz some people said there is some fault with the DCMI module . i also have confusion about the DMA_SxNDTR Reg in the DMA .... what does the number of data items mean? ... bytes or word or 4-word transaction ?2014-07-22 07:06 PM
The F205 doesn't have DCMI, pretty sure the F207 does, but you can review the errata.
The Transfer Count for the DMA is 16-bit, and can represent 65535 transactions of 1, 2 or 4 BYTE. So with 32-bit words, a maximum of just shy of 256KB Is any of the buffer filling with data? If you fill the buffer with a known pattern you should be able to discern how much. What if the buffer is internal SRAM?