AnsweredAssumed Answered

STM32F072 USB cdc device sending data to PC

Question asked by dsok on Oct 23, 2014
Latest reply on Oct 24, 2014 by sung.chen_chung
Hello everybody

I am trying to make VCP work on  STM32F072 discovery board. I have written a program to send data from device to PC with the help of ST example code and this discussion:  STM32F072 DISCO USB cdc device sending data to PC
Device is showing up as a COM port when i plug it, but i am not getting any data on a terminal. I dont know what i am doing wrong, maybe someone could give me a clue.
Thanks in advance.

This is my main.c
/* Includes ------------------------------------------------------------------*/
#include "usbd_cdc_core.h"
#include  "usbd_usr.h"
#include "usbd_cdc_vcp.h"
/* Private function prototypes -----------------------------------------------*/
LINE_CODING linecodingg =
    115200, /* baud rate*/
    0x00,   /* stop bits-1*/
    0x00,   /* parity - none*/
    0x08    /* nb. of bits 8*/
USART_InitTypeDef USART_InitStructure1;
extern uint8_t  APP_Rx_Buffer []; /* Write CDC received data in this buffer.
                                     These data will be sent over USB IN endpoint
                                     in the CDC core functions. */
extern uint32_t APP_Rx_ptr_in;    /* Increment this pointer or roll it back to
                                     start address when writing received data
                                     in the buffer APP_Rx_Buffer. */
extern uint16_t VCP_DataTx1   (uint8_t* Buf, uint32_t Len);
extern uint16_t VCP_Init     (void);
extern uint16_t VCP_DeInit   (void);
extern uint16_t VCP_Ctrl     (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
extern uint16_t VCP_DataRx   (uint8_t* Buf, uint32_t Len);
CDC_IF_Prop_TypeDef VCP_fops =
/* Private functions ---------------------------------------------------------*/
extern uint16_t VCP_DataTx1 (uint8_t* Buf, uint32_t Len)
  uint32_t i=0;
       GPIO_SetBits(GPIOC, GPIO_Pin_9);
        GPIO_SetBits(GPIOC, GPIO_Pin_7);
        GPIO_SetBits(GPIOC, GPIO_Pin_8);
        GPIO_SetBits(GPIOC, GPIO_Pin_6);
    while(i < Len)
        APP_Rx_Buffer[APP_Rx_ptr_in] = *(Buf + i);
        /* To avoid buffer overflow */
        if(APP_Rx_ptr_in == APP_RX_DATA_SIZE)
            APP_Rx_ptr_in = 0;
  return USBD_OK;
int main(void)
  uint8_t work[4] = {0x57,0x6f,0x52,0x6b};
  UserToPMABufferCopy(work, INT_IN_TX_ADDRESS, 4);
  SetEPTxCount(ENDP1, 4);
  while (1)
    VCP_DataTx1  (work, 4);