-
怎么取代法?
-
8.4.6.4 Function Response to a SETUP Transaction
SETUP defines a special type of host-to-function data transaction that permits the host to initialize an
endpoint’s synchronization bits to those of the host. Upon receiving a SETUP token, a function must accept
the data. A function may not respond to a SETUP token with either STALL or NAK, and the receiving
function must accept the data packet that follows the SETUP token. If a non-control endpoint receives a
SETUP token, it must ignore the transaction and return no response.
——原来,usb2.0协议中的确规定,setup令牌包不能响应NAK,那么问题会否就是OUT指令回复ack后host就发了下一个setup,而此时接收缓冲区的控制权sie在设置trnif中断时已经交还给了cpu,无法再次接收数据了,所以就没有响应?
那么问题是否只有通过开启pp缓冲区就能解决?
-
还怀疑过是控制寄存器误动作将UEP0的握手使能位关闭了,但是通过串口输出这个寄存器值,却一直没有改变过。
莫非pic单片机对于837.625us的延迟下无法工作?(out和setup get dsc cfg之间的延迟时间是837.625us)但为何后续又是可以的呢……莫非是因为对于in和out才能发nak,而对setup不能?百思不得其解……
-
注:以上现象我实验了很多种时钟配置,还发现PLL开了以后时钟高电平脉宽不稳定,而上升沿是准确的,怀疑过是PLL开启的问题,后来关闭了PLL,尝试了以下几种模式,均出现相同问题,以此排除PLL问题:
1,开PLL,CPU-48Mhz,全速sie 48Mhz
2,关PLL,CPU-12Mhz,usb时钟除以2,低速sie-6Mhz
3,开PLL,CPU-48Mhz,usb时钟除以2,低速sie-6Mhz
-
沉底了。。莫非现在大家都不玩pic了么?呵呵
终于搞定了,还好有个逻辑分析仪,不知道是不是时钟配置的问题,用了12Mhz的晶振,开了片内4倍速PLL,cpu工作在48Mhz,手册中注明采用低速模式时“可能需要一定的延迟”,汗~极度不严谨,可能?也就是说不一定需要。一定的延迟?到底要多少个指令周期?也没有说明。但是即便这样,我用全速模式也还是存在同样问题,按照时序发现以下动作,虽然删除了一些导致延迟的代码目前已经OK了,但对于这个现象还是很值得研究,是否能避免呢,具体如下,请大家一起分析下:
1,……(这里省略get dsc dev前的枚举动作描述)
2,[host -> dev] SETUP
[host -> dev] DATA get device descriptor (len:18)
[host dev] IN(注:这之前有很多个IN都响应NAK,表示SIE还没有准备好发送)
[host dev] ack
——trnif中断(固件将第9字节开始的8个字节放到发送缓冲区,将缓冲区控制权交回SIE)
4,[host -> dev] IN(注,同上,这之前有很多个IN都响应NAK,表示SIE未准备好发送数据
[host dev] ack
——trnif中断(固件将最后两个字节放到缓冲区,同上处理,启动SIE发送)
5,[host -> dev] OUT
[host -> dev] DATA (注:空数据包,表示已经收到完整数据)
[host dev] SETUP
[host -> dev] DATA get config descriptor (len:255)
[host -> dev] SETUP
[host -> dev] DATA get config descriptor (len:255)
[host -> dev] SETUP
[host -> dev] DATA get config descriptor (len:255)
——这时cpu还未响应TRNIF OUT中断,就发生了以上第六点的数据动作,但是奇怪的是这时SIE完全没有响应 NAK或者ACK。。。导致枚举中断,总线发了复位信号
7,总线上发了复位信号
8,——trnif中断(固件响应OUT中断,但因为总线已经复位,枚举又回到1重新开始,同样到第六步这里卡住,重复4次后,枚举失败)
-
扫描了总线上的数据,到这一步就变成这样了,不知道为何对setup get_dsc(config) 来的时候,sie 完全没响应。。
2.056227958 USB 4 Digital 4 IN Add:10 EndPoint:0
2.056254292 USB 4 Digital 4 DATA1 0 1 dev
2.056291708 USB 4 Digital 4 ACK
2.056321458 USB 4 Digital 4 OUT Add:10 EndPoint:0 2.975E-05
2.056347708 USB 4 Digital 4 DATA1 host 0 no trnif
2.056374125 USB 4 Digital 4 ACK
2.057816292 USB 4 Digital 4 SETUP Add:10 EndPoint:0 0.001442167
2.057842542 USB 4 Digital 4 GET DESCRIPTOR CONFIG Length:255
2.057842542 USB 4 Digital 4 DATA0 80 6 0 2 0 0 FF 0
2.057935292 USB 4 Digital 4 SETUP Add:10 EndPoint:0 9.275E-05
2.057961542 USB 4 Digital 4 GET DESCRIPTOR CONFIG Length:255
2.057961542 USB 4 Digital 4 DATA0 80 6 0 2 0 0 FF 0
2.058054292 USB 4 Digital 4 SETUP Add:10 EndPoint:0
2.058080542 USB 4 Digital 4 GET DESCRIPTOR CONFIG Length:255
2.058080542 USB 4 Digital 4 DATA0 80 6 0 2 0 0 FF 0
-
Init()
Main()
>>> Trun On USB()...
-->ATTACHED_STATE
-->POWERED_STATE
>>> Suspend()... SLEEP... WAKe_UP...
>>> Wake Up()...
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>> Suspend()... SLEEP... WAKe_UP...
>>> Wake Up()...
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 00 00 00 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {00 00 00 00 00 00 00 00 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::GET_DSC
USBStdGetDscHandler()-->DSC_DEV:Tx Serv() ->ctrl_trf_state = CTRL_TRF_TX
>>TRNIF()
USTAT = {04 }
ep0Bo = {44 00 80 02 }
ep0Bi = {64 08 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {12 01 10 01 00 00 00 08 }
>> In()... Data stage
Tx Serv()
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 08 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::SET_ADR
-->ADR_PENDING_STATE
->ctrl_trf_state = CTRL_TRF_RX
>>TRNIF()
USTAT = {04 }
ep0Bo = {C8 08 88 02 }
ep0Bi = {64 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> In()... -->ADDRESS_STATE : addr is : 1
Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>TRNIF()
USTAT = {00 }
ep0Bo = {88 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Out()... Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::GET_DSC
USBStdGetDscHandler()-->DSC_DEV:Tx Serv() ->ctrl_trf_state = CTRL_TRF_TX
>>TRNIF()
USTAT = {04 }
ep0Bo = {44 00 80 02 }
ep0Bi = {64 08 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {12 01 10 01 00 00 00 08 }
>> In()... Data stage
Tx Serv()
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 08 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::SET_ADR
-->ADR_PENDING_STATE
->ctrl_trf_state = CTRL_TRF_RX
>>TRNIF()
USTAT = {04 }
ep0Bo = {C8 08 88 02 }
ep0Bi = {64 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> In()... -->ADDRESS_STATE : addr is : 1
Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>TRNIF()
USTAT = {00 }
ep0Bo = {88 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Out()... Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::GET_DSC
USBStdGetDscHandler()-->DSC_DEV:Tx Serv() ->ctrl_trf_state = CTRL_TRF_TX
>>TRNIF()
USTAT = {04 }
ep0Bo = {44 00 80 02 }
ep0Bi = {64 08 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {12 01 10 01 00 00 00 08 }
>> In()... Data stage
Tx Serv()
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 08 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::SET_ADR
-->ADR_PENDING_STATE
->ctrl_trf_state = CTRL_TRF_RX
>>TRNIF()
USTAT = {04 }
ep0Bo = {C8 08 88 02 }
ep0Bi = {64 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> In()... -->ADDRESS_STATE : addr is : 1
Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>TRNIF()
USTAT = {00 }
ep0Bo = {88 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Out()... Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::GET_DSC
USBStdGetDscHandler()-->DSC_DEV:Tx Serv() ->ctrl_trf_state = CTRL_TRF_TX
>>TRNIF()
USTAT = {04 }
ep0Bo = {44 00 80 02 }
ep0Bi = {64 08 88 02 }
SetupPkt = {80 06 00 01 00 00 40 00 }
CtrlTrfData = {12 01 10 01 00 00 00 08 }
>> In()... Data stage
Tx Serv()
>>> Reset()...
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
-->DEFAULT_STATE
>>TRNIF()
USTAT = {00 }
ep0Bo = {34 08 80 02 }
ep0Bi = {00 08 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> Setup()...
->ctrl_trf_state = WAIT_SETUP
StdRequest() >>> ::SET_ADR
-->ADR_PENDING_STATE
->ctrl_trf_state = CTRL_TRF_RX
>>TRNIF()
USTAT = {04 }
ep0Bo = {C8 08 88 02 }
ep0Bi = {64 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {8F 0E 03 00 07 01 01 02 }
>> In()... -->ADDRESS_STATE : addr is : 1
Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>TRNIF()
USTAT = {00 }
ep0Bo = {88 08 80 02 }
ep0Bi = {00 00 88 02 }
SetupPkt = {00 05 01 00 00 00 00 00 }
CtrlTrfData = {80 06 00 01 00 00 12 00 }
>> Out()... Status stage
USBPrepareForNextSetupTrf()->ctrl_trf_state = WAIT_SETUP
>>> Suspend()... SLEEP... WAKe_UP...
-
由于文件内容超出版面长度,只发了部分数据,请大家帮忙看看调试数据.txt,用ue可以看到2进制结果
-
好东东,楼主真有创意,有了这工具,以后焊板就方便了。知不知道稳定不?
-
感谢LZ分享!
-
真贵~兴币能换钱么~
-
强烈建议楼主出本pdf的书啊
-
支持!
-
4楼正解
-
先下载,有空学习,帮顶
-
赞同,还是李开复的那句话:follow your heart!
-
加油!支持勤奋的人!
-
额。。为何不用更高的版本?貌似很多年前就用bc6了。。
-
支持共享,壮大国内电子技术
-
感激,很好的资料