cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 USB, HID or VCP

p23
Associate II
Posted on May 18, 2015 at 15:29

Hello everyone,

I'm working on a project where I have to use the USB functionality of the STM32F072CB and I'm not sure how I should use it in the end.

The job of the STM32F0 in my application is to programm another controller (STM32F1) and some other stuff. The programming of the STM32F1 should be done via USB.

Therefore I have to get the data from a PC and programm the other controller.

My question(s) are:

1. What is the best mode to do this? HID or VCP? I'm tending to the VCP variant because I can use any terminal on my PC.

2. I tried this one out a little. I created the source code via the cubemx. The PC recognizes the controller as a com port. My problem is, that I don't want to use the HAL. Simply because I've already written some code for my application and I don't have the time to get into using the HAL.

I've searched for some example for the STM32F0. I found an example for the HID or for STM32F1 VCP but I could find a example for the STM32F0 VCP. Is there any little example I haven't found yet?

It would be nice if you could give me your feedback

#stm32f0-usb-vcp
2 REPLIES 2
qwer.asdf
Senior
Posted on May 18, 2015 at 17:36

1. I would use VCP (but use CRC checksums to verify that the received data is valid before flashing it)

2. If you don't want to use HAL then generating a project with STM32Cube is useless (it supports only HAL). You should download 

http://www.st.com/web/en/catalog/tools/PF257884

and

http://www.st.com/web/en/catalog/tools/PF257928

and use them instead. You will find examples in the USB library.

p23
Associate II
Posted on May 19, 2015 at 09:56

Hello,

I got into the HAL thing yesterday and I think I'll use it. But thank you for your response.

I got one more question...

The USB ISR looks like that:

/**

* @brief This function handles USB global interrupt.

*/

void USB_IRQHandler(void)

{

  /* USER CODE BEGIN USB_IRQn 0 */

  /* USER CODE END USB_IRQn 0 */

  HAL_PCD_IRQHandler(&hpcd_USB_FS);

  /* USER CODE BEGIN USB_IRQn 1 */

  /* USER CODE END USB_IRQn 1 */

}

The ISR gets called if I'm sending data via a terminal to the vcp. My question now is: Where is my data stored?

I thought it would be in the ''hpcd_USB_FS'' structure (pData) but it seems to be not.

Sorry for the ''newbe'' question, but I'm not that into it yet.