cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Com Port for STM32F103XC

1605mystery
Associate II
Posted on April 07, 2014 at 12:44

Hi Guys,

I Am trying to port VCP Example Project found in STM32_USB-FS-Device_Lib_V4.0.0 on STM32F103XE Eval kit.

Pin Description :

PA12------USBDP-------Pulled up by 1.5K Resistor.

PA11------USBDM

PA10------USART1_RX

PA9--------USART1_TX

So depending on same I modified as below

void Set_System(void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

    /*Set PA11,12 as IN - USB_DM,DP*/

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;

   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  //GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

 

  /*SET PA11,12 for USB: USB_DM,DP*/

  // GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);

 //  GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);

}

As GPIO_PinAFConfig is obsolete in latest standard peripheral library ( STM32F10x_StdPeriph_Lib_V3.5.0 ) so how can I set Pin11 and Pin12 as DM\DP ?

Is there any substitute or how to configure same ?

Regards,

 

Omji Mishra

#usb-stm32
11 REPLIES 11
Posted on April 07, 2014 at 13:40

GPIO_PinAFConfig() isn't used by ANY STM32F1 library because it uses different methods to associate pins/peripherals.

You shouldn't need to change PA11/PA12, all boards are using these for FS USB

What board are you using? Cite a web page for the board.

The STM3210E-EVAL and STM3210B-EVAL should have existing support in ST projects.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
1605mystery
Associate II
Posted on April 08, 2014 at 08:36

Hi,

Thanks for replying.

Am using

STEVAL-IDX001V1

Eval Kit from ST.

Am working with latest libraries and have done changes in standard Virtual COM Project provided with USB libraries. As per my understanding:

I have configured USB disconnect pin as PA12 for USB.

and have changed PA9, PA10 for USART1.

Still it's not working, so need your suggestion in solving same.

Am attaching schematics for your reference.

Regards,

Omji Mishra

________________

Attachments :

steval-idx001v1_schematic.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Zc&d=%2Fa%2F0X0000000baf%2F0wOOh9i4z4DpuN24jjgR4.K8H8ryHwSzKqAcqXhG_bQ&asPdf=false
Posted on April 08, 2014 at 08:50

Your most probable issue is the boards use of a 16 MHz external source, you need to use the HSE in BYPASS mode, and reconfigure the PLL setting to account for the different source clock. USB will require a 48 MHz clock (nominally from 72 / 1.5). This code is likely in system_stm32f10x.c

The project will also need HSE_VALUE defined as 16000000
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
1605mystery
Associate II
Posted on April 08, 2014 at 09:06

Hi Clive,

Am configuring clocks using below function :

static void prvSetupHardware( void )

{

 /* Start with the clocks in their expected state. */

 RCC_DeInit();

 /* Enable HSE (high speed external clock). */

 RCC_HSEConfig( RCC_HSE_ON );

       

 /* Wait till HSE is ready. */

 while( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) == RESET )

 {

 }

 /* 2 wait states required on the flash. */

 *( ( unsigned long * ) 0x40022000 ) = 0x02;

 /* HCLK = SYSCLK */

 RCC_HCLKConfig( RCC_SYSCLK_Div1 );

 /* PCLK2 = HCLK */

 RCC_PCLK2Config( RCC_HCLK_Div1 );

 /* PCLK1 = HCLK/2 */

 RCC_PCLK1Config( RCC_HCLK_Div2 );

 /* PLLCLK = 8MHz * 9 = 72 MHz. */

 RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 );

 /* Enable PLL. */

 RCC_PLLCmd( ENABLE );

 /* Wait till PLL is ready. */

 while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

 {

 }

 /* Select PLL as system clock source. */

 RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK );

 /* Wait till PLL is used as system clock source. */

 while( RCC_GetSYSCLKSource() != 0x08 )

 {

 }

 /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */

 RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC

       | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );

 /* SPI2 Periph clock enable */

 RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );

 /* Set the Vector Table base address at 0x08000000 */

 NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );

 NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );

 /* Configure HCLK clock as SysTick clock source. */

 SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK );

}

and also have configured clock 

 #define HSE_VALUE    ((uint32_t)16000000)

Regards,

Omji Mishra

Posted on April 08, 2014 at 09:18

 /* Enable HSE in BYPASS mode, source is an XO */

 RCC_HSEConfig( RCC_HSE_Bypass);

..

 /* PLLCLK = 16MHz / 2 * 9 = 72 MHz. */

 RCC_PLLConfig( RCC_PLLSource_HSE_Div2, RCC_PLLMul_9 );
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
1605mystery
Associate II
Posted on April 08, 2014 at 09:47

Hi,

I have done configuration as suggested by you.

Still its not working.

Disconnect pin and usart have been configured as discussed above.

PowerOn(void) returns USB_SUCCESS and lands nowhere.

JTAG needs to be disconnected and further debugging is not possible.

Also further configurations I guess are not done as in Virtual_Com_Port_init().

Regards,

Omji Mishra

Posted on April 08, 2014 at 09:56

I have done configuration as suggested by you. Still its not working.

I don't have one of these boards, so can only suggest you analyze the differences between your board, and the example targets, and make any/all modifications require to port it. To do any more analysis at my end you'll need to send me a board to work with.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
1605mystery
Associate II
Posted on April 08, 2014 at 11:11

Hi Clive,

I will do comparative study and try solving issue.

I have one doubt regarding USB Disconnect pin.

As you can see in schematic that Eval Kit we are using has no USB Disconnect Pin.

But the eval kit for demo project has one and they configured same.

So should I drop the configuring of USB Disconnect pin ?

And also as you said above that PA12 and PA11 (USBDP & USBDM) are configured by default in max board. So my ques is that how a pin functionality is choosen in ST board as these are memory mapped ?

Regards,

Omji Mishra

1605mystery
Associate II
Posted on April 11, 2014 at 09:05

Hi ,

Now after some code modification I am able to get the status as attached i.e. USB ISR reset is executed properly.

But it at never points shows status as configured.

Am checking status in a task:

void check_usb( void * pvParameters )

{

     while(1)

     {

         if( bDeviceState == UNCONNECTED )

             Led_Red(OFF);

         if( bDeviceState == ATTACHED )

             Led_Red(ON);

         if( bDeviceState == CONFIGURED )

             Led_Yellow(ON);

         if( bDeviceState != CONFIGURED )

             Led_Yellow(OFF);

     }

}

What can be possible reason that my device is not getting detected on PC and I don't get configured status for my device ?

 

 

On PC I get status as device malfunctioned and its not detected as virtual com port.

Waiting for your reply !!!!!!

Regards,

 

Omji

Mishra