cancel
Showing results for 
Search instead for 
Did you mean: 

CMOS data pass to ethernet interface throguh DMA channel

simonlee0311
Associate II
Posted on March 24, 2012 at 04:32

Dear All:

I try to pass my CMOS data to ethernet interface through DMA. (Before transfer to ethernet interface, I will add bmp file header.)

I already show the CMOS data on my LCD. But I don't have any idea how to pass data to ethernet interface.

I have readed the sample code, LwIP, which in stander library director.

My plan is add my CMOS control code in LwIP (httpserver-standalone project).

Anyone has experience or idea about this? Would you please give me some idea to do this?

Thanks.

34 REPLIES 34
simonlee0311
Associate II
Posted on April 20, 2012 at 09:40

Dear all:

 

 

I already fixed all issue. But I still can't show the picture on web side.

 

I try to use netconn_write() to pass the data. 

 

I already save the data at Ex-SRAM.

 

Does anyone has same experience about this issue?

 

Please, if you know about this. Please share your experience with me.

 

Many thanks.

 

 

Simon

 

 

Here is the part of my code.

 

 

        if (strncmp((char const *)buf,''GET /Web_files/test.bmp'',23)==0)

 

        {

 

 netconn_write(conn, fileheader, sizeof(fileheader), NETCONN_NOCOPY);

 

 netconn_write(conn, (const unsigned char*)(0x60000000), 1024, NETCONN_COPY);

 

 

 

        }   

 

 

simonlee0311
Associate II
Posted on April 20, 2012 at 15:26

Dear all:

I've tested all the way that I would like to. But sill not work.

I modify from official sample which is httpserver_conn. (wih LwIP)

My function is capture the image from CMOS and pass it to web side. (BMP File)

Please any experience in this area, please do a favor for me.

I'm sure that the composition of the data is correct.

Many thanks,

Simon

Posted on April 20, 2012 at 19:10

Can you save the BMP file from your web browser?

Is the file the correct size?

Is the header correct for the dimensions of the image?

Can you load the saved file and view it in Paint/PhotoShop?

You don't provide the header data so it's pretty hard to check if it looks correct or not.

You could do a checksum or CRC of the data you're creating on the chip side, you could confirm this on the PC side.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
amin23
Associate II
Posted on April 20, 2012 at 19:45

Hi,

- Ext. SRAM address should be: 0x64000000

- The image size should be 240x320x2 when using QVGA format or 1601x120x2 when using QQVGA format

- The image header should contain http image herder + MBP image header see attached file.

Below the correct code:

if (strncmp((char const *)buf,''GET /Web_files/test.bmp'',23)==0)

{

netconn_write(conn, fileheader, sizeof(fileheader), NETCONN_NOCOPY);

netconn_write(conn, (const unsigned char*)(0x64000000), sizeof(image), NETCONN_COPY);

}

________________

Attachments :

ImageHeader.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtTx&d=%2Fa%2F0X0000000aQb%2FZd7cd1r2C.U7FNjuspJuzRK62u1RowYnp6TdDLkuvb4&asPdf=false
amin23
Associate II
Posted on April 20, 2012 at 19:46

Hi,

- Ext. SRAM address should be: 0x64000000

- The image size should be 240x320x2 when using QVGA format or 1601x120x2 when using QQVGA format

- The image header should contain http image herder + MBP image header see attached file.

Below the correct code:

if (strncmp((char const *)buf,''GET /Web_files/test.bmp'',23)==0)

{

netconn_write(conn, fileheader, sizeof(fileheader), NETCONN_NOCOPY);

netconn_write(conn, (const unsigned char*)(0x64000000), sizeof(image), NETCONN_COPY);

}

________________

Attachments :

ImageHeader.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1K4&d=%2Fa%2F0X0000000blG%2FxV32lmfV9QK3K37GInsD_9gwbrdTGj9Mm63XcNT0YJA&asPdf=false
alok472
Associate II
Posted on April 21, 2012 at 05:02

Hi Simon,

1. At this stage you will probably need an Ethernet analyser like Wireshrk or Ethereal. Only then you will be able to confirm if the data is correctly sent or not.

2. Another approach i will take is to check the Ethernet layer. This can be done by avoiding the CMOS image capture and taking a fixed BMP image on STM32F2 and then checking if it can be displayed on the Web browser. Once this is done, you can integrate the CMOS.

3. For the network between STM32F2 and your web-client, are they in same Subnet ? Or are you trying from Internet, (That will be too far !) Pls have a local network fisrt to check your system works.

simonlee0311
Associate II
Posted on April 23, 2012 at 06:11

Dear all:

First of all thanks for your kindly support. 

Thank you for the reminder with explain.

Finally, I found it was my header file fail. (About this issue, much thanks Clive1, AMSN and Alokm.)

Now I set my platform and PC at same net domain.

It works now, I can see the picture on web side. 

Even if it is garbled type.

I think it should be noise which cause by beginning of DCMI.

Now, I also try to re-capture again, when receive the request form web side.

But the program will crashed and no response.

Why? I can't let free run and when receive the request then responses the request to pass data to web side? Do I need to reconfigure DCMI and DMA again?

The below is my setting of DMA. 

Also please correct me if I set an error.

At the same time I will try to solve my problem. I am willing to share with you my settings after the completion of this. 

I also hope that can help to other friends who has similar problems with me.

Best regards,

Simon

/* Configure the DMA2 for DCMI */

void DMA_Config(void)

{

  DMA_InitTypeDef  DMA_InitStructure;

  /* Configures the DMA2 to transfer Data from DCMI to External SRAM using double buffer mode*/

  /* Enable DMA2 clock */

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);  

  

  /* DMA2 Stream1 Configuration */  

  DMA_DeInit(DMA2_Stream1);

  DMA_InitStructure.DMA_Channel = DMA_Channel_1;// in reference maual only DMA2_Stream1/Channel1 can for DCMI function

  DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS; //notice here is DMA_PeripheralBaseAddress (PAR)

  DMA_InitStructure.DMA_Memory0BaseAddr = SRAM_BANK1_ADDRESS; //notice here is DMA_Memory_0(M0AR)

  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

  DMA_InitStructure.DMA_BufferSize = 9600;//BufferSize = 1 by PeripheralDataSize_Word(32b) =32b=4B=2pixel. means 4byte transfers one time

  /* 320*120=38400 pixel, DCMI one time 4 byte. so BufferSize = 38400/9 = 9600 and the address = 38400 */

  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//external address increase disable

  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //RAM address increase disable

  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; 

  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; 

  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA_Mode_Normal ; 

  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_DoubleBufferModeConfig(DMA2_Stream1, SRAM_BANK1_ADDRESS+(0x2580*4),DMA_Memory_0); //DMA double buffer configure

  DMA_DoubleBufferModeCmd(DMA2_Stream1, ENABLE); //enable DMA double buffer mode    

  

  DMA_Init(DMA2_Stream1, &DMA_InitStructure); 

}  

/*------------------------------- 

Camera capture image subroutine

00H return is capture finish

FFH return is capture fail

-------------------------------*/

void Camera_Capture_Image(void)

{

/*Disable any old interrupt before enabling DMA

 Warning: This is not specified in the reference manual, but MUST be done before enabling steam.

*/

DMA_ClearITPendingBit( DMA2_Stream1, DMA_IT_TCIF1 | DMA_IT_HTIF1 | DMA_IT_DMEIF1 | DMA_IT_FEIF1);

/*Reset DMA buffer address before starting transfer is will be more safety*/

DMA2_Stream1->M0AR = SRAM_BANK1_ADDRESS; //set M0AR = SRAM_BANK1_ADDRESS

DMA_DoubleBufferModeConfig(DMA2_Stream1, SRAM_BANK1_ADDRESS+(0x2580*4),DMA_Memory_0); //DMA double buffer configure

  DMA_DoubleBufferModeCmd(DMA2_Stream1, ENABLE); //enable DMA double buffer mode

  DMA_ITConfig(DMA2_Stream1, DMA_IT_TC, ENABLE); // enable DMA2_Stream1 transfer complete interrupt 

DMA_Cmd(DMA2_Stream1, ENABLE); // enable DMA transfer immediatly

while(DISABLE == DMA_GetCmdStatus(DMA2_Stream1)); //wait for DMA to start-up

DCMI_Cmd(ENABLE); // enable DCMI interface

DCMI_ITConfig(DCMI_IT_FRAME, ENABLE); //enable Frame capture complete interrupt mask 

  DCMI_CaptureCmd(ENABLE);  // Start Image capture

  

while( 0== DCMI_GetFlagStatus(DCMI_FLAG_FRAMERI)); // check Frame capture complete Raw flag mask

DCMI_CaptureCmd(DISABLE); // disable DCMI capture

DCMI_Cmd(DISABLE); // disable DCMI

DMA2_Stream1->M0AR = SRAM_BANK1_ADDRESS; //set M0AR = SRAM_BANK1_ADDRESS

DMA_DoubleBufferModeConfig(DMA2_Stream1, SRAM_BANK1_ADDRESS+(0x2580*4),DMA_Memory_0); //DMA double buffer configure

DMA_Cmd(DMA2_Stream1, DISABLE); //disable DMA2 stream1

while(ENABLE == DMA_GetCmdStatus(DMA2_Stream1)); // wait for DMA stop

//return(0x00);

}

amin23
Associate II
Posted on April 23, 2012 at 12:54

Hi,

Please refer to the attached txt file, i have added few comments.

________________

Attachments :

code.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtU2&d=%2Fa%2F0X0000000aQd%2FolX7n.4PRx3EH2O_DBd3zc83KHyX60niBl7YSW5xlKI&asPdf=false
alok472
Associate II
Posted on April 24, 2012 at 07:34

Corrupted image can be because same data in buffer is being accessed by DCMI (for filling) and Ethernet (for emptying) Together. Pls make sure new image is filled once the old image has been streamed on the Ethernet.

So start the DCMI DMA once the Ethernet full image transfer is done.

simonlee0311
Associate II
Posted on April 24, 2012 at 15:14

Hi Friends:

Very grateful to you to remind me to have a direction to find the answer.

It works now. Maybe not good enough, but

I can finally see the image!!! (Thank you guys.)

The image as the attachment. ( I know it is very terrible!!)

I think I need more time to adjust it. (

Maybe I simply can not find the perfect setting. BCZ datasheet, sample code, and app note.

three settings are not the same.)

Oh! I try to write some java script in the web side to read the image.Because official sample using refresh method to re-load the web page.

So, I try to use java script to read the imagerepeatedly.(Java script list at below.)

When I finished the java script which already tested at my PC web browser, then I put it

in the platform. And ? Guess what? It didn't work!!!! Why? It can work on my PC!!!

Do I have what details did not notice?

Simon

JAVA SCRIPT:

<head>

<meta http-equiv=''Content-Type'' content=''text/html; charset=UTF-8''>

<title>TASKS</title>

<!-- <meta http-equiv=''refresh'' content=''1''> -->

<meta content=''MSHTML 6.00.2800.1561'' name=''GENERATOR''>

<style =''font-weight:='''' normal;='''' font-family:='''' verdana;''=''''></style>

<script type=''text/javascript''>

function change_image()

{

document.getElementById(''pic'').src = ''/test.bmp'';

setTimeout(''change_image1()'',100);

}

function change_image1()

{

document.getElementById(''pic'').src = ''/test.bmp'';

setTimeout(''change_image()'',100);

}

</script>

</head>

<body onload=''change_image()''>

________________

Attachments :

__0180.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtKs&d=%2Fa%2F0X0000000aLh%2Fm_d8vHwN51gQYu5eIeOZF48cGNCJyXOSrq8FgCHx7.w&asPdf=false