Hi Danny,
Thank you for your help. I think I have got a key in my case and like to share with you and other friends.
My system is based on a IS10 DEV kit from Altera, uses Nios2/f cpu. UDP transmition runs on ucos II as a task. My work is to collect image(320*256 pixels,16bit) into SDRAM and send they to a host. Here is my UDP routine:
# define TOTAL_UDP 160 // total packets, 1K bytes a packet# define UDP_EACH_DATA 1024 // bytes,# define UDP_PAYLOAD_BYTES UDP_EACH_DATA+2 // add index number of
packet
volatile int num_udp_completed=0;
void SSSUDPSendTask()
{
struct netconn *conn;
struct netbuf *buf;
struct ip_addr addr;
INT8U err;
unsigned short* udp_packet_addr;
unsigned int udp_addr_offset;
int j;
/* confique connection to host as UDP */
conn = netconn_new(NETCONN_UDP);
/* set up the IP address of the remote host */
addr.addr = htonl(HostIPAddress);
/* connect the connection to the remote host */
netconn_connect(conn, &addr, HostUDPPortNum);
/* create a new netbuf */
buf = netbuf_new();
while(1)
{
// wait for a semaphore from DMA task
OSSemPend(CAMDMAFinishSem,0,&err);
for(j=0;j<4;j++) // send 2k pixels each time
{
/* set the base and offset address of UDP packet */
udp_addr_offset = UDP_EACH_DATA * num_udp_completed;
udp_packet_addr = (unsigned short*)(dma_data_base + udp_addr_offset-2);
/* insert index before data */
*udp_packet_addr = num_udp_completed;
/* reference the data into the netbuf */
netbuf_ref(buf, (unsigned char*)udp_packet_addr, UDP_PAYLOAD_BYTES);
netconn_send(conn, buf);
num_udp_completed++;
}
if (num_udp_completed == TOTAL_UDP)
{
num_udp_completed = 0;
}
} //while(1)
}
Now in my system the time spending on collecting 100 frame pictures has decreased from 40.5 to 7 sec via following steps.
(1) move phrases (netconn_new().. buf =) to outside while(1) loop as above routine shows. this makes the time drop from 40.5 to 20.2 seconds.
(2) next step, use your udp.c routine, the time reaches 15.4 sec. i doubt if the lwip calculates checksum for each element of data.
(3) change the compile option, configuration, from Debug to Release. that is in c/c++builder of properties of myproject and myproject_syslib. the time is 7 sec.
The result is not bad although something still let me maze.
Thanks to you again,
Cheers,
Johnd