阅读:1334回复:3
速度只有20K,大家看看我的程序有什么问题!!!!
一.固件中的程序有关数据发送的部分如下:
//定时器0中断处理 timer0_isr() interrupt 1 { DISABLE; TH0 = TH0_init; TL0 = TL0_init;//上位机设置发送速度 EpBuf[0]++;//检查是否会丢数据 bSend=1;//发送标志置位 ENABLE; } //mainloop循环中发送部分 if(bSend){ bSend=0; //发送标志复位 D12_WriteEndpoint(5,64,&EpBuf);//发送64个字节 } 二.App中读数据部分 do{ time0=GetTickCount(); //接受前时间 bResult = ReadFile(hFile, threadParam->pcIoBuffer, threadParam->uiLength,//=64,如果设为大于64的值,则程序会死掉 &nBytes, NULL); threadParam->ulCount += nBytes; time1=GetTickCount();//接收后时间 if (bResult != TRUE) {//只要连接正确,接收都正确 DeviceIoControl(hFile, IOCTL_D12_RESET_PIPE, 0,0,0,0,&nBytes, NULL); threadParam->bInThread = FALSE;//退出线程 wsprintf (cc, \"Reading \"); strcat( cc, threadParam->pipe_name); strcat( cc, \" failed! Aborted.\"); testDlg->MessageBox((LPCSTR)cc, \"Test Error\"); break; } else{ threadParam->total_time += (time1-(threadParam->Last_time)); threadParam->Last_time=time1; if(time1 != time0){//计算速度 threadParam->cur_rate = (2*nBytes*1000)/(time1-time0); threadParam->bUpdate = TRUE; } } }while(threadParam->bInThread == TRUE); 三.驱动中有关代码(我对写驱动一点不会,也不可能把代码都贴出来,找了一段我觉得可能有关系的,大家看看) 问题: 1.下位机发送间隔大于3ms时能正确接收,速度在20KBps左右, 发送间隔小于该值时,可以接收,但数据会丢很多,而且速度也只有20K多一点。 2.斑竹给我写的信中指出: \"Because you transfer only 64 bytes from ur driver! Why not make a bigger one? In fact, ur driver can issue a URB with 32768 bytes transfer if u want. Of cause this need u modify ur driver\'s EP settings. The modifications are different for DS or DDK based driver. I have only done this with DS driver.\" 请问是改驱动代码中的设置呢,还是固件中端点描述符就可以了呢? 大侠们帮帮忙 //bow :( |
|
沙发#
发布于:2002-09-29 08:30
我最近也正解决同样的问题,我想这可能和好多原因有关,固件占的主要的,另别还和上位机的程序有关,比如缓冲大小。总之要协调好!
请问你的芯片是不EZr的?采用的是何种类型的设备? |
|
板凳#
发布于:2002-09-29 10:48
也可能固件中
|
|
地板#
发布于:2002-09-29 11:32
MCU太慢了。
89C5?的吧。 |
|
|