Skip to main content
its
Associate III
November 1, 2012
Question

simultanous DMA filling and USART Tx from memory + camera output

  • November 1, 2012
  • 31 replies
  • 5921 views
Posted on November 01, 2012 at 07:56

hi:

I have interfaced camera with STM32F4 discovery. currently I am capturing the frame and after the first capture is complete, I disable Camera capture and start sending data from memory over USART2. it sequential. and works fine.

now , I want to send data over USART2 at the same time as after each DMA memory location filled by camera DATA.

Or i want to send the first frame data from DMA0 buffer while at the same time the next frame data will be filling to DMA1 buffer.(in double buffer mode)

is it possible.  and how>? any hint....

#dcmi-dma-camera #dma #usart #dcmi #wait-for-you--clive1-!-!-!
This topic has been closed for replies.

31 replies

its
itsAuthor
Associate III
November 21, 2012
Posted on November 21, 2012 at 09:57

@ simon

              do you have PCB or using wire connections?

Tesla DeLorean
Guru
November 21, 2012
Posted on November 21, 2012 at 13:30

What does USART3_SendData() look like?

Sending 50KB in a burst to a PC serial port might be overwhelming, are you using any flow control?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
simonlanghart9
Visitor II
November 21, 2012
Posted on November 21, 2012 at 16:03

@tech.haris 

@clive1

thanks for your support, I checked again my code several hours again, i solved the problem, now it works fine.

I changed these parts:

/************************************/

//new Buffer Size:

uint32_t frame_buffer[176*144];

/************************************/

//new DMA Buffer Size:

DMA_InitStructure.DMA_BufferSize = (sizeof(frame_buffer)/sizeof(uint32_t));

DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; //not essential

/************************************/

//and the new UART send routine as follow:

void USART3_SendFrame(void)

{

int t i;

for(i = 0;i < (sizeof(frame_buffer)/sizeof(uint32_t)); i++)

//for(i=0;i<352;i++)

//for(i=0;i<40000;i++)

{

USART3_SendData((uint16_t)frame_buffer[i]);

USART3_SendData((uint16_t) (frame_buffer[i] >> 8));

USART3_SendData((uint16_t) (frame_buffer[i] >> 16));

USART3_SendData((uint16_t) (frame_buffer[i] >> 24));

}

}

/************************************/

Anyway thanks for your time, maybe i need your help another time

Simon

its
itsAuthor
Associate III
November 22, 2012
Posted on November 22, 2012 at 06:05

it kind a basic question,, but I want to know exact sysclck operating in STM32F4 Discovery, in example projects. 

HSE=8 Mhz

HSI=?

PLL=?

thanks

Tesla DeLorean
Guru
November 22, 2012
Posted on November 22, 2012 at 06:12

For settings review STM32F4-Discovery_FW_v1.1.0\Project\Audio_playback_and_record\src\system_stm32f4xx.c

PLL = 336 MHz

HSI = 16 MHz
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
its
itsAuthor
Associate III
November 23, 2012
Posted on November 23, 2012 at 06:53

and

SYSCLK=?

thanks
Tesla DeLorean
Guru
November 23, 2012
Posted on November 23, 2012 at 13:32

From the cited file :

*=============================================================================
* Supported STM32F4xx device revision | Rev A
*-----------------------------------------------------------------------------
* System Clock source | PLL (HSE)
*-----------------------------------------------------------------------------
* SYSCLK(Hz) | 168000000
*-----------------------------------------------------------------------------
* HCLK(Hz) | 168000000
*-----------------------------------------------------------------------------
* AHB Prescaler | 1
*-----------------------------------------------------------------------------
* APB1 Prescaler | 4
*-----------------------------------------------------------------------------
* APB2 Prescaler | 2
*-----------------------------------------------------------------------------
* HSE Frequency(Hz) | 8000000
*-----------------------------------------------------------------------------
* PLL_M | 8
*-----------------------------------------------------------------------------
* PLL_N | 336
*-----------------------------------------------------------------------------
* PLL_P | 2
*-----------------------------------------------------------------------------
* PLL_Q | 7
*-----------------------------------------------------------------------------
* PLLI2S_N | 258
*-----------------------------------------------------------------------------
* PLLI2S_R | 3
*-----------------------------------------------------------------------------

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
its
itsAuthor
Associate III
November 26, 2012
Posted on November 26, 2012 at 06:58

hi,

  I have buffer, which is initialized by 'O' in sensor_check() function, filled by DCMI through DMA after a frame capture. when I show its content in main () through USART over hyperterminal, it depict very right result. but when I call the same routine in WaveRecorderUpdate(void) from waverecorder.c some intial portion about 300 bytes of the image data is coruptted  with 'O', from which i have initialized the buffer. any idea?

     main()

   {

      ...

      ....

  /* SysTick end of count event each 10ms */

  RCC_GetClocksFreq(&RCC_Clocks);

  SysTick_Config(RCC_Clocks.HCLK_Frequency  / 100);

 

  /* Initialize the repeat status */

  RepeatState = 0;

  LED_Toggle = 7;

 

#if defined MEDIA_IntFLASH

 

  WavePlayBack(I2S_AudioFreq_48k);

  while (1);

 

#elif defined MEDIA_USB_KEY

 

  /* Initialize User Button */

  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);

   

  /* Init Host Library */

  USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);

 init_usart();          

 check_sensor();

frame_capture();   // after commenting both of these lines frame_capture and while(1)

while(1);         //     i call the frame_capture through  WaveRecorderUpdate(void) which  called 

                     //         deep in USR_Callbacks. I use the same software flow of audio recorder.

 while (1)

  {

          /* Host Task handler */

                  USBH_Process(&USB_OTG_Core, &USB_Host);

                  

  }

 

#endif

 

}

WaveRecorderUpdate(void)

{

 frame_capture();

}

if data was like this 130 2 130 2 130 2 130 2 130 (which is start code of frame)

I got this from WaveRecorderUpdate(void) 79 79 79 79 79 79 79 (which is ascii for 'O')

remaining data is same. and image is constructed with little bit errors.

thanks.
its
itsAuthor
Associate III
December 26, 2012
Posted on December 26, 2012 at 05:27

the problem in last post is solved. the problem is occurring as i am shutting down DMA immediately after next frame detection or some time due to high frequency of PCLK.

I have memory constraints to hold image data greater than 32768 bytes. Can I use external RAM/memory for that to overcome this limitation so that I can get high resolution image data? will that fast enough for DMA to write there from DCMI_DR?

vinothraj
Associate III
January 28, 2013
Posted on January 28, 2013 at 12:04

@simon:

 How to view the image is taken from the uart??