阅读:1148回复:3
关于USBN9604的开发
请各位高手给我参谋一下,小弟在开发USBN9604时发现,在初始化程序结束后,接到PC时,PC不能枚举出设备,只是告知“未知设备”,用仿真器观察,发现在读MAEV寄存器时,未收到“RX_EV”事件,仅有“ALT”事件!我用51总线读写,9604工作于非复合状态。初始化、中断代码如下,附件中只原理图。
void init_usb() { byte b; waitseconds(); waitseconds(); write_usb(CCONF,0x0b); b = read_usb(MCNTRL); write_usb(MCNTRL,0x05); while(read_usb(MCNTRL) & 0x01) _nop_(); write_usb(MCNTRL,0xc4); write_usb(FAR,0x80); write_usb(EPC0,0x00); write_usb(MAMSK,0xd6); write_usb(ALTMSK,0xd0); write_usb(TXMSK,0xff); write_usb(RXMSK,0xff); write_usb(NAKMSK,0xff); write_usb(NFSR,0x02); write_usb(TXC0,0x08); write_usb(RXC0,0x01); waitseconds(); write_usb(MCNTRL,0xcc); } void SignalInt() interrupt 0 { byte event; event = read_usb(MAEV); if(event & RX_EV) { event = read_usb(RXEV); if (event&0x11) { rx0(); } else if(event&0x22) { rx1(); } else {} } else if(event & NAK) { event = read_usb(NAKEV); if (event & 0x10) { write_usb(TXC0,FLUSH); write_usb(RXC0,FLUSH); write_usb(TXC0,0x00); write_usb(RXC0,0x01); } _nop_(); } else if(event & TX_EV) { event = read_usb(TXEV); if (event&0x11) { tx0(); } else if (event&0x22) { tx1(); } else {} } else if(event & ALT) { event = read_usb(ALTEV); if (event&0x40) { write_usb(EPC0, read_usb(EPC0) & ~STALL); write_usb(NFSR,0x00); write_usb(FAR,0x80); write_usb(EPC0,0x00); write_usb(TXC0,0x08); write_usb(RXC0,0x01); write_usb(NFSR,0x02); } else if (event&0x10) { Addr_Reg=ALTMSK; Data_Reg=0xc0; Addr_Reg=NFSR; Data_Reg=0x03; } else if (event&0x80) { write_usb(ALTMSK,0x50); write_usb(NFSR,0x02); } else { } } } |
|
沙发#
发布于:2004-02-27 17:49
我现在也遇到了这样的问题,调了很久了,还是没有找到原因,郁闷呀?
|
|
|
板凳#
发布于:2002-08-05 08:55
可以,但是我现在没什么头绪
|
|
地板#
发布于:2002-08-01 10:24
你好,我们也马上要做USBN9604,可否交流一下。
|
|
|