2014-07-26 08:18 PM
I have been trying to get the OV7670 cam working with STM32F207zg but seems like something is not clear , first i need to know what is the buffer size to set the DMA to when i want to transfer a snapshot from the cam to External SRAM (since i can not directly send it to the LCD) , say i want 240 * 320 pixels (RGB565) , and the external RAM is 16-bit wide , so what should be the buffer size for the DMA ? ........
also im not sure if the documentation is clear about the VSYNC and HSYNC , the camera module has the VSYNC active high (i,e Data r not sampled when its high) and HSYNC active low , so what should the DCMI settings for VSYNC and HSYNC ? with the following code , i get DMA FIFO ERROR , and I get the frame flag set , but when i display the frame (even if not complete) , the LCD shows noise DMA_InitTypeDef DMA_DCMI; // Configure the DCMI // 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 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=2; NVIC_Init(&NVIC_DCMI); // // NVIC_DCMI.NVIC_IRQChannel=DMA2_Stream1_IRQn; NVIC_DCMI.NVIC_IRQChannelCmd=ENABLE; NVIC_DCMI.NVIC_IRQChannelPreemptionPriority=1; NVIC_DCMI.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_DCMI); // // 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 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; DMA_DCMI.DMA_Memory0BaseAddr = 0x64000000; DMA_DCMI.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_DCMI.DMA_BufferSize = 320*240*2; 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 DMA_Cmd(DMA2_Stream1, ENABLE); /* Enable DCMI interface */ DCMI_Cmd(ENABLE); /* Start Image capture */ DCMI_CaptureCmd(ENABLE); // // // . . . void DCMI_IRQHandler() { if (DCMI_GetITStatus(DCMI_IT_VSYNC) != RESET) { DCMI_ClearITPendingBit(DCMI_IT_VSYNC); } if (DCMI_GetITStatus(DCMI_IT_LINE) != RESET) { DCMI_ClearITPendingBit(DCMI_IT_LINE); } if (DCMI_GetITStatus(DCMI_IT_FRAME) != RESET) { DCMI_ClearITPendingBit(DCMI_IT_FRAME); for(count=0; count<76800 ; count++) { LCD_REG=0x22; LCD_RAM=BUFF[count]; } } if (DCMI_GetITStatus(DCMI_IT_ERR) != RESET) { DCMI_ClearITPendingBit(DCMI_IT_ERR); } } .. .. Any ideas? ...... Is it cam settings , is it the DCMI ? >>>>>> thx in advance .2014-07-28 08:29 AM
Hi,
the ov7670 default format is VGA 640x480(yuv422) = 307200 pixel. 2 Byte per pixel = 614400 Bytes per Frame. Pixelclock is freerunning (default), rising edge=datavalid. VSYNC needs to be low for valid capture.(active low) HREF needs to be high for valid capture.(active high) There is no HSYNC by default. Its the HREF signal being issued, connect it to DCMI-HSYNC. (active high)2014-07-28 09:14 AM
Can we PLEASE STOP creating new threads about materially the same topic, it's really annoying.
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Problem%20with%20DCMI%20FRAME%20interrupt&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx?Paged%3DTRUE%26p_StickyPost%3D%26p_DiscussionLastUpdated%3D20140724%252018%253a20%253a57%26p_ID%3D44564%26View%3D%257bF47A9ED8%252dE726%252d42BE%252dACED%252d732F13B66581%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41¤tviews=25]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex%5fmx%5fstm32%2fProblem%20with%20DCMI%20FRAME%20interrupt&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex%5Fmx%5Fstm32%2FAllItems%2Easpx%3FPaged%3DTRUE%26p%5FStickyPost%3D%26p%5FDiscussionLastUpdated%3D20140724%252018%253a20%253a57%26p%5FID%3D44564%26View%3D%257bF47A9ED8%252dE726%252d42BE%252dACED%252d732F13B66581%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41¤tviews=25 You can't set the DMA to do more than 65535 transactions, it's a 16-bit register!2014-07-28 12:55 PM
Thx for ur reply Krueger , but i understand all what u said , i just do not know what the problem might be , if u have used this cam before , i would appreciate if u point to some code .
Clive its the same topic but different Issues , and about the DMA length i know what u saying too , but i do not exactly get the meaning of ''Item'' , the sheet says number of items , is it word or byte or half word , this is the first time i suffer from that issue for DMA , i used it before with SDIO , and obviously i could read n write up to 6 M/B per time , but i know it was different case as the Peripheral was the flow controller , not the DMA .2015-04-22 07:41 AM
Hello
I can write to registers but can't read them, what is the reason?I supply xclk pin with 42MHz sysclk coming from MCO2.Thanks.2015-06-28 07:27 AM
Hello
My problem was solved, unfortunately it was related to stm32cubef4 software package.2015-06-29 03:58 AM
Hi tag.aseok,
In various posts, you said: ''My problem was solved, unfortunately it was related to stm32cubef4 software package. ''.Could you please explain how was your problem related to STM32CubeF4?Was it a wrong usage from your side or a bug in the package?What are the updates you made to fix it?This may help other users to fix similar issue. And if there is a bug in the Cube package, we can fix it also.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-07-01 11:26 PM