2011-08-29 08:31 AM
Hello at all...
I'm developing a camera that acquires a frame when it has a trigger and stores the data in the external ram with the DMA. The camera has a relolution 1280 x 1024 pixel (each one of 16bit) and all pins signal are compatibles with the DCMI interface on the micro STM32F207. I begun with the DCMI example in the ST-library but it's work with low resolution 320x240 pixel. I configured the DMA as below: DMA_InitTypeDef DMA_InitStructure; /* Enable DMA2 clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); DMA_ClearFlag(DMA2_Stream1, DMA_FLAG_FEIF1 | DMA_FLAG_DMEIF1 | DMA_FLAG_TEIF1 | DMA_FLAG_HTIF1 | DMA_FLAG_TCIF1); /* DMA2 Stream3 or Stream6 disable */ DMA_Cmd(DMA2_Stream1, DISABLE); /* DMA2 Stream3 or Stream6 Config */ DMA_DeInit(DMA2_Stream1); DMA_InitStructure.DMA_Channel = DMA_Channel_1; DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) pBufferPtr; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 1; 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_HalfWord; DMA_InitStructure.DMA_Mode = 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_FlowControllerConfig(DMA2_Stream1, DMA_FlowCtrl_Peripheral); My problem is that the max resolution that I can use is 128 x 1024 = 131072 pixel. I suppose that the reason is the DMA counter limitations on 16 bit (65536) because each transfer on DMA is of 2 pixel (32 bit) and the max tranfer is 131072 pixel The flow controller is configured to acquire the data controlled by the peripheral. Could anyone suggest me any solution to increase the acquiring resolution?2014-02-20 05:10 AM
Hi Omede Marco, I am also working on the same kind of project. Can you post your code here. It might be helpful to a lot of peoples working with STMcontrollers. Thanks
2014-04-11 02:13 PM
Hi. I'm also working with a camera (0v7670). I have two problems that i have not been able to solve for a week or more.
Firstly, myDCMI->DR is always 0x00000000. I don't know why, since my interrupts work fine (no overflows or errors), and i am able to count the right number of lines per picture (480). I really cannot see the reason why i just read 0s!
My second problem: how does the DMA know at what speed he has to transfer data from
DCMI->DR to my address in RAM? I guess this should be done with PCLK...is it? I am asking this because if i set
DMA_SetCurrDataCounter(DMA2_Stream1, 320*240*2/4) (to move only to RAM 320*240 pixels), and it takes 17 frames to the DMA to transfer the data, and only transfers data in between frames (when line= 480), 1176 words each time!!?¿?
As i understand things, to me it would be more logical if the DMA transferred the first 320*240 pixels of the first frame and then ended his job.
I attached my code. Any help is welcome. Thank you! ________________ Attachments : dcmi.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1Ih&d=%2Fa%2F0X0000000bky%2Feo9uvwzo6GSHV2YThAZu13Px3nhv8HKvgbdfQ2LghqM&asPdf=falsemain.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I18e&d=%2Fa%2F0X0000000bkz%2FdV5L.enAACpLbCZr4ppjD7FaOKaW0ao2HP_rz_n3yuY&asPdf=false2014-04-11 04:01 PM
The data is clocked at the rate prescribed by PCLK, which can be up to 50-54 MHz as I recall.
Is the camera connected directly? Or is it using a FIFO chip? What board do you have it attached too?2014-04-12 03:45 AM
Thanks Clive1, you're always helping everybody.
i'm with smt32f429. The camera doesnt have any fifo.My final goal is to have two cameras, capture two frames and then compute a disparity map. My algorithm for disparity map works fine, but with images from internet. I only need to be able to take pictures with two cameras, and then do image rectification.
The data is clocked at the rate prescribed by PCLK, which can be up to 50-54 MHz as I recall
i have tried my code with PCLK= from 16MHz to 250KHz(configuring the camera with sccb). no difference.Could you guess a reason why it takes 17 frames to transfer the data?i really can not imagine why.Thank youu2014-04-12 05:04 AM
That's a chip, what board are you using? (The STM32F429I-DISCO has pin contention between the LCD and DCMI as I recall)
Have you put a scope on the interface pins? Looked at the PCLK, V/H SYNC? The DCMI interface should be capable of single frame capture, It's just a method of parallel data input, most of the configuration, and issues related to the data stream, are controlled by the camera itself.2014-04-12 10:17 AM
yes sorry the discover board.
i put a scope in all my pins and my signals work fine (for example I see how PCLK's frequency changes when i modify the specified registers with sccb).Indeed, I saw that some of the pins I use are connected to the LCD, but I thought that if I didn't use the LCD I could connect those pins to my camera setting them in AF. Am I wrong and those pins can only be used for LCD purposes?2014-04-12 10:20 AM
I forgot to mention that in Snapshot mode I get an overflow error all the time, something that never happens in continuous mode.
2014-04-16 08:21 AM
Hi,
The example below show how to manage DMA transfer when the buffer size is more than (65536*4) bytes - The DMA is used in simple mode - Use access registers directly to avoid overflow error ****************************** __IO uint8_t TCindex = 0, void DMA2_Stream1_IRQHandler(void) { if(DMA_GetITStatus(DMA2_Stream1, DMA_IT_TCIF1) != RESET) { /* Clear interrupt pending bit */ DMA2->LIFCR = DMA_IT_TCIF1; if(TCindex == 0) { DMA2_Stream1->M0AR = 0x64040000; DMA2_Stream1->NDTR = 0xFFFF; DMA2_Stream1->CR |= 0x00000001; TCindex++; } else if(TCindex == 1) { DMA2_Stream1->M0AR = 0x64080000; DMA2_Stream1->NDTR = 0x5802; DMA2_Stream1->CR |= 0x00000001; TCindex++; } else if(TCindex == 2) { TCindex = 0; DMA2_Stream1->M0AR = 0x64000000; DMA2_Stream1->NDTR = 0xFFFF; /* DMA2 Stream1 disable */ DMA_Cmd(DMA2_Stream1, DISABLE); /* Disable DCMI interface */ DCMI_Cmd(DISABLE); /* Disables the DCMI Capture. */ DCMI_CaptureCmd(DISABLE); /* Buffer is filled */ ...... } } else if(DMA_GetITStatus(DMA2_Stream1 ,DMA_IT_TEIF1) != RESET) { /* Clear interrupt pending bit */ DMA_ClearITPendingBit(DMA2_Stream1, DMA_IT_TEIF1); } }2014-04-22 08:42 AM
Hi,
I just found out that I had to configure my dcmi like this:DCMI_InitStruct.DCMI_PCKPolarity =
DCMI_PCKPolarity_Falling
; I don't understand why, because in the OV7670's datasheet in my opinion the data is valid when the PCLK is rising...Thanks anyway2014-04-22 03:43 PM
''I don't understand why, because in the OV7670's datasheet in my opinion the data is valid when the PCLK is rising...''
It may look like that in the datasheet but thats because the PCLK shown is at it's max. Look closely at tPDV - PCLK[goes neg] to data out valid = 5ns + tSU (Data setup time) = 15ns (That caught me as well).