cancel
Showing results for 
Search instead for 
Did you mean: 

Can not use MCO output in VirtualComport_Loopback project

chenbo
Associate
Posted on April 25, 2014 at 15:16

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-stm32f103vct6
2 REPLIES 2
Posted on April 25, 2014 at 15:33

[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&currentviews=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); //??

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
chenbo
Associate
Posted on April 26, 2014 at 15:58

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) 

{

...

}