-
GD32F105RB 使用官方USB例程,运行至枚举状态机时进入死循环
将外部晶振修改为8M之后,打印主频96M,一切正常,但是USB的时钟源是未进行修改,应为我主频没变,时钟配置如下voidusb_rcu_config(void){uint32_tsystem_clock=rcu_clock_freq_get(CK_SYS);printf("系统时钟为:%d\n",system_clock);if(48000000U==system_clock){usbfs_prescaler=RCU_CKUSB_CKPLL_DIV1;timer_prescaler=3U;}elseif(72000000U==system_clock){usbfs_prescaler=RCU_CKUSB_CKPLL_DIV1_5;timer_prescaler=5U;printf("系统时钟为:%d\n",system_clock);}elseif(96000000U==system_clock){usbfs_prescaler=RCU_CKUSB_CKPLL_DIV2;timer_prescaler=7U;}else{/*reserved*/}rcu_usb_clock_config(usbfs_prescaler);rcu_periph_clock_enable(RCU_USBFS);}但是运行至枚举状态机时就卡死在死循环不出来,这是为什么呢进入caseHOST_DEV_ENUM:之后:调用usbh_devdesc_get(uhost,8U))-----》》》usbh_ctl_handler(uhost);------》》》if(URB_DONE==usbh_urb_wait(uhost,uhost->control.pipe_in_num,DATA_STAGE_TIMEOUT)){uhost->control.ctl_state=CTL_STATUS_OUT;}就卡死在这个等待
2022-10-09 5