cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 USB VCP Demo Code Problems

ryansturmer2
Associate II
Posted on August 01, 2010 at 17:44

STM32F103 USB VCP Demo Code Problems

#stm32
11 REPLIES 11
Nickname12657_O
Associate III
Posted on May 17, 2011 at 14:00

Dear Sturmer,

Could you please attach the schematics of your Softbaugh board  for a sanity check versus our Evaluation boards by ST ?   be aware that this Sofbaugh board is fitted by our ''STM32F103RC'' : High density devices. Equivalent to our STM32E-EVAL workspace not STM32B-EVAL.  let me know you comments.

Cheers

STOne-32.

ryansturmer2
Associate II
Posted on May 17, 2011 at 14:00

I'm unfortunately not able to share the schematics of the demo board.  The USB part of the circuit is identical to the EVAL-B, with a jumperable USB_DISCONNECT pin.  I have it set to PORTC bit 13, and have made that known in hardware_platform.h   Other than memory size, what are the differences between the medium/high density devices?  Will these matter for the USB peripheral?

domen23
Associate II
Posted on May 17, 2011 at 14:00

Just an idea.

Try compiling without optimization (-O0). I've often cursed example code (from another company), that was buggy, but happened to work when optimizations were disabled.
xacc
Associate II
Posted on May 17, 2011 at 14:00

The only problem I have had, was getting the pull up to work correctly.

I had several problems when the pull up activates before the USB interrupts are started.

ryansturmer2
Associate II
Posted on May 17, 2011 at 14:00

I'm already compiling with optimization off, so that's not likely the issue.

The circuit I have is slightly different than the ST version with regards to the pull-up.  I'm fairly new to USB... Is DP supposed to be pulled up when USB is active, and pulled down when disabled?  Or is it the other way round?  Or have I missed the mark altogether?

xacc
Associate II
Posted on May 17, 2011 at 14:00

If just connected with a pin, then the code must change slightly.

Here is my changes:

void Set_System(void)

{

  GPIO_InitTypeDef GPIO_InitStructure;

  /* Enable USB_DISCONNECT GPIO clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE);

  GPIO_DeInit(USB_DISCONNECT);  // make sure it's default

  /* Configure USB pull-up pin */

  GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // change from OD to PP

  GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);

}

void USB_Cable_Config (FunctionalState NewState)

{

  if (NewState == DISABLE)  // opposite

  {

    GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);

  }

  else

  {

    GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);

  }

}

Nickname12657_O
Associate III
Posted on May 17, 2011 at 14:00

Hi,

DP, should be up when VBUS ( 5 Volts from cable)  is detected present and you should enumerate the device within 10ms from ''USB reset'' else the host will cut the connection and DP down when VBUS is not present.

Cheers,

STOne-32.

ryansturmer2
Associate II
Posted on May 17, 2011 at 14:00

The pin is tied to a PMOS that connects DP to VDD through a 1.5k resistor.  Pulling it DOWN should turn it ON, which should enact the pullup.  I've tried this configuration with both the push-pull and open-drain modes on the output, with no success.  I'm pretty sure that the GPIO is working, but I supposed I should scope the DP line to be sure.

Paul UHS
Associate II
Posted on May 17, 2011 at 14:00

From: sturmer.ryan.001

Subject: STM32F103 USB VCP Demo Code Problems

The function Virtual_Com_Port_Reset(), which appears to be the function that configures the endpoints and activates the USB hardware does not appear to even be called by the demo code.  What gives?

The Virtual_Com_Port_Reset() is called via the Device_Property.Reset(); in void USB_Istr(void) when the host requests the slave to reset. So if your getting NO activity it is likely that the USB pull-up are not working (as has been mentioned in the thread)