cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 USB communication

jean2
Associate II
Posted on March 07, 2014 at 17:27

Hi Hi, 

I have done some test using the USART1 PA9 and PA10 pin to communicate with my arduino board, i made some basic configuration like this : 

USART_InitTypeDef USART1_Init;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

USART1_Init.USART_BaudRate = 19200;

USART1_Init.USART_WordLength = USART_WordLength_8b ;

USART1_Init.USART_StopBits = USART_StopBits_1;

USART1_Init.USART_Parity = USART_Parity_No;

USART1_Init.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART1_Init.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

USART_Init(USART1, &USART1_Init);

USART_Cmd(USART1, ENABLE);

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

NVIC_EnableIRQ(USART1_IRQn);

It work very good ^^ but there is something i don't understand : 

  I guess i could use this USART1 to communicate with a computer via FTDI chip, but the STMf103 has two pins PA11 and PA12 (usbdm and usbdp) which should be made to be directly connected to the usb. So how can i use PA11 and PA12 to send and receive data from my computer? Is there any documentation on this or library?

 If i use also PA9 and PA10 for other purpose (like connecting USART to my GPRS shield) would the usb/computer connection PA11 and PA12 be affected as they are on the RTS and CTS of the USART1?

thanks a lot for your help 🙂

1 REPLY 1
chen
Associate II
Posted on March 07, 2014 at 18:04

Hi

The STM32F103 part does not seem to have great support in terms of demo software source code.

Here are the most promising dev boards :

http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF204176?s_searchtype=keyword

http://www.st.com/web/en/catalog/tools/FM116/SC1075/PF253384?s_searchtype=keyword

http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1199/PF259443

Study the circuit diagrams from each to understand how to implement the USB circuit.

None of them have links to a page with source code.

I note this part is only USB Full speed (I work with the F4 parts which are USB OTG)

This link takes you to the library/source code for the USB Full Speed library for your part:

http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/PF258157?s_searchtype=keyword

It may have examples (I do not know)

If the USB does not use the same pins as the USART (which it does not look like it does), you should be able to use both at the same time.