2014-04-25 06:16 AM
Hi, all,
I use STM32F103VCT6 and VirtualComport_Loopback project for usb communication, the usb part works fine. Now, I try to output the MCO at PA8, failed.void MCO_Config(void){ GPIO_InitTypeDef is; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); is.GPIO_Pin = GPIO_Pin_8; is.GPIO_Speed = GPIO_Speed_50MHz; is.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA,&is); RCC_MCOConfig(RCC_MCO_SYSCLK); return;}int main(void){ Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); MCO_Config(); while (1) { if (bDeviceState == CONFIGURED) { CDC_Receive_DATA(); /*Check to see if we have data yet */ if (Receive_length != 0) { if (packet_sent == 1) CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length); Receive_length = 0; } } }} If I add a breakpoint before while loop, i got MCO at PA8, but ,when I continue, the MCO will disappear. I do find that the RCC->CFGR had been changed somewhere, but I can not find it. Anyone can give me help ? Thanks a lot. BTW, the Virtualcomport_lookback project comes from STM32_USB-FS-Device_Lib_v4.0.0. #mco-vcp-usb-stm32f103vct62014-04-25 06:33 AM
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F103%20%20can%27t%20%20config%20MCO%EF%BC%88PA8%EF%BC%89%20and%20USB%20CLK%20together&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=23]Related?
Perhaps you should just enable the MCO after the USB clock? Perhaps your debugger is breaking things? The USB clock selection using bit-banding, not sure it should matter, you could away access the register directly. RCC->CFGR |= (1 << 22); //??2014-04-26 06:58 AM
Thanks for your help.
We found problem happended in the usb configure process.Problem solved by: while (1) { if (bDeviceState == CONFIGURED) { MCO_Config(); break; } } while (1) { ...}