我的程序是网上公开的JB16 BDM程序,但硬件做好后接上USB线,USB中断服务程序只产生SUSPEND/RESUM中断和复位中断,没有EP0接收中断或SETUP中断。
我现在不知道是硬件问题还是软件问题,是不是在接收除复位中断外其它中断前先要在PC上装好驱动?
初学USB,还望大虾们多多指教。多谢啦!!!
这是USB初始化代码。
void usb_init(void) {
usb_ep0_dcntT=0xff; /* special meaning - means no transmission in progress */
usb_ep0_dcntR=0; /* no data to receive */
usb_ep2_dcntT=0; /* no data to transmit */
usb_ep2_dcntR=0; /* no data to receive */
led_timer=0;
led_state=LED_ON;
LED_INIT; /* usb interrupt drives the LED, so make sure it is initialised */
UADDR = UADDR_USBEN_MASK; /* enable the USB module, assign address to the default value (0) */
UIR0 = UIR0_RXD2IE_MASK | UIR0_RXD0IE_MASK | UIR0_TXD2IE_MASK | UIR0_TXD0IE_MASK | UIR0_EOPIE_MASK; /* enable Rx&Tx interupts on EP0 & EP2, enable end of frame interrupt */
UCR0 = 0; /* reset EP0 */
UCR1 = 0; /* reset EP1 */
UCR2 = 0; /* reset EP2 */
UCR4 = 0; /* normal operation */
UCR3 = UCR3_TX1STR_MASK | UCR3_PULLEN_MASK; /* clear TX1ST & enable internal pull-up */
USB_State = US_POWERED; /* must be powered when running this code... */
}作者: koukou147 时间: 2007-7-7 09:40