cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4,DCMI connect DMA

Hüseyin Varl?k
Associate II
Posted on March 19, 2017 at 16:44

The original post was too long to process during our migration. Please click on the attachment to read the original post.
8 REPLIES 8
S.Ma
Principal
Posted on March 19, 2017 at 17:28

Until an expert answers the question (the code being too big for my quick browsing), some preliminary thoughts.

There was another post similar where the RS232 transmission was interrupted during the transfer.

Take a snapshot: Start DCMI and push a full frame in a SRAM area. (because the bitrate of DCMI is too high compared to RS232 to be synchroneous, you'll have to drop frames).

Once a full frame is transfered to RAM, let the DMA trash out further bytes cycling through dummy RAM bytes buffer;

Then use the RS232 DMA to push the frame onto UART. Once the transmission is complete, re-plumb DMCI byte feeding to the frame buffer from the next top frame (VSYNC)

Hüseyin Varl?k
Associate II
Posted on March 19, 2017 at 21:23

You are right the code too big. Just one point important for me. My purpose DCMÄ° connect to DMA tihis my code . it is true or false ?

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);

/* DMA2 Stream1 Configuration */

DMA_DeInit(DMA2_Stream7);

DMA_InitStructure.DMA_Channel = DMA_Channel_4;

DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;

DMA_InitStructure.DMA_Memory0BaseAddr = USART2_ADDRESS; //DEGISIKLIK YAPT

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

DMA_InitStructure.DMA_BufferSize = sizeof(USART2-> DR); //320 * 240 / 2;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;

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_Stream7, &DMA_InitStructure);

DMA_ITConfig(DMA2_Stream7, DMA_IT_TC, ENABLE);

DMA_Cmd(DMA2_Stream7, ENABLE);

USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);

USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);

}
Posted on March 19, 2017 at 21:33

while(1)

{

//sprintf(str,' stm pojem ');

//sprintf(data,'Okunan Data=0x%02X',temp);

int *ptr;

while ((DCMI_GetFlagStatus(DCMI_FLAG_FNE)) == RESET) //Waiting for the buffer

TIM_Cmd(TIM3, DISABLE); //Disable CAM clock

*ptr = (DCMI->DR);

USART_Gonder(USART2,str);

*ptr= (DCMI->DR)>>16; //Reading 2nd part of the buffer

USART_Gonder(USART2,*ptr);

TIM_Cmd(TIM3, ENABLE);

...

I don't have the time/resources to wade into all this.

The above is problematic, assuming you capture a frame.

The ptr is not initialized, and writing to it, and using string functions doesn't make any logical sense.

If DCMI->DR is a 32-bit value, you'd do better reading it into a variable, and then outputting those as a fixed length byte stream.

uint32_t dr;

dr = DCMI->DR;

USART_SendBuffer(USART2, sizeof(uint32_t), &dr); // Send 4-byte word

void USART_SendBuffer(USART_TypeDef* USARTx,size_t Size, unsigned char *Buffer)

{

  while(Size--)

  {

    while(!(USARTx ->SR & 0X00000040));

    USART_SendData(USARTx,*Buffer++);

  }

}

Make sure you configure the board to use an 8 MHz clock, and that HSE_VALUE is 8000000, and not 25000000

if (SysTick_Config(SystemCoreClock / 3119))//1ms

The USART isn't going to be able to sustain the rate of data coming from the DCMI peripheral. You'd need to DMA the video frame data into memory from the DCMI, and then when you have a frame push that out via the USART. You have one interface capable of >100MBps and another doing 10KBps, so a disparity of 4 orders of magnitude.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 19, 2017 at 21:36

I don't see this working. The address would be &USART2->DR, and wouldn't increment.

The bigger issue is that the DCMI is generating data 10000x the rate USART can send it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Hüseyin Varl?k
Associate II
Posted on March 20, 2017 at 00:45

Turvey.Clive.002

My board setting : USE_STDPERIPH_DRIVER,STM32F4XX,HSE_VALUE=8000000

Purpose of my project. I must take video and send computer by USART. When I debug code ,I can see data in DCMI. How can I transfer data from DCMI to DMA . After draw data from DMA to USART2 ?

Posted on March 20, 2017 at 03:01

 ,

 ,

Ok, I understand the project, I'm not looking to code or debug it, break it into pieces you can test and debug.

Here is an example of using DMA with a USART, it could be adapted to output blocks of data

 ,

You'd need to adapt to USART2, changing the DMA, Stream, Channel to match.

For DCMI+DMA, I'd suggest you review the SPL examples, and those for the STM32F4-DIS-CAM, bit outside my area of interest. If you have the mechanics of the camera and DCMI down already, the DMA should be a matter of the Stream/Channel described in the Reference Manual (RM0090). Now the other issue would be size, as the transfer is limited to 65535 transfer units. Double buffering might be able to extend that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Hüseyin Varl?k
Associate II
Posted on March 20, 2017 at 10:00

thanks

Turvey.Clive.002

Centauris.Alpha

Martin.Sergio
Associate III
Posted on March 21, 2017 at 11:03

Hi,

You can start with STM32Cube_FW_F4_V1.0 Aplication and examples

The application 'STM32469I_EVAL\Applications\Camera\Camera_To_USBDisk' use transfer from DCMI to LCD using DMA,

You can adapt this easy to modify the Transfer from DCMI to Memory using DMA and use

Turvey.Clive.002

example toTransfer from Memory to Peripheral (UART) using DMA

Sergio