驱动牛犊
|
阅读:1137回复:2
紧急求救 (USB数据通信)
我开发了基于JB16的USB设备,采用BULK传输方式.
在固件程序是这样做的,有个全局数组为缓冲区buf[128],接受(对设备而言)是开始于buf[1],发送开始于buf[0],为何我只能发数字+其他,也就是说第一位必须是数字? PC发送1wwwwwww PC接受wwwwwww1 并且第一位只是可以发送0到7的数字. 为什么? 请高手指点!! 难道我的固件程序的问题! 怎么解决啊? |
驱动牛犊
|
沙发#
发布于:2008-04-04 14:49
怎么没有人回答啊
|
驱动牛犊
|
板凳#
发布于:2008-04-04 19:07
问题搞好了
是固件程序的问题 贴出来同大家分享: 我的EP2接受函数: void USB_ep2_rx(void) { /* EP2 receives the messages in raw format (size of cmd+data, cmd, data0, data1, ...) */ unsigned char * ptr=&UE2D0; if (usb_ep2_dcntR==0) { /* if the routine is called with no data to be received, it must be beginning of a message */ UCR2_TX2E=0; /* disable EP2 transmitter */ usb_ep2_dcntR=UE2D0; (((((((问题所在)))))))) usb_dptr=command_buffer; ptr = &UE2D1; /* skip copying the size */ } while ((ptr<((&UE2D0)+8))&&(usb_ep2_dcntR)) { *(usb_dptr++) = *(ptr++); /* copy data */ usb_ep2_dcntR--; /* decrement count */ } if (usb_ep2_dcntR==0) { /* command reception complete */ usb_ep2_dcntT = command_exec(); usb_dptr = command_buffer; USB_ep2_tx(); /* start transmitting the data */ } } 全局变量惹的祸啊 |