Skip to main content
hassan2
Associate II
December 10, 2015
Question

Virtual Com Port on Nucleo-F072RB

  • December 10, 2015
  • 5 replies
  • 1323 views
Posted on December 10, 2015 at 22:48

I am new here. Starting using Nucleo-F072RB. I can see the Virtual Com Port on my PC when I connect USB cable to the ST-Link board. The ST-Link Debug device also shows up in device manager. I am able to flash the board with new firmware.

Can I use the same USB cable to send and receive data through the VCP?

I tried using the CDC_Standalone application for the STM32072b_EVAL project, but I am not getting anywhere right now. 
    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    December 11, 2015
    Posted on December 11, 2015 at 05:07

    You are confusing things here. The VCP provided by the ST-LINK manifests as pins attached to a physical USART of the STM32F072RB. There is no VCP/CDC USB firmware on the part you are programming.

    Something like this should suffice,

    /* USART2 PA.2 Tx, PA.3 Rx STM32F0xx sourcer32@gmail.com */
    #include ''stm32f0xx.h''
    int main(void)
    {
    USART_InitTypeDef USART_InitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
    /* Configure USART2 pins: Rx and Tx ----------------------------*/
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
    USART_InitStructure.USART_BaudRate = 115200;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    USART_Init(USART2, &USART_InitStructure);
    USART_Cmd(USART2,ENABLE);
    while(1)
    {
    while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
    USART_SendData(USART2, 'X');
    }
    }

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    jbeck17
    Visitor II
    December 11, 2015
    Posted on December 11, 2015 at 14:06

    If you still need to be able to implement USB on the chip, adding an external connector will suffice. The firmware packages that are available are setup for the individual boards and you need to know the differences if you are going to use the code. The Nucleos need an external crystal to use some of the eval code which is how I implemented USB MSC on my nucleoF401. The schematics and app notes will help you in knowing what pins to connect to what for the connector.

    Tesla DeLorean
    Guru
    December 11, 2015
    Posted on December 11, 2015 at 15:04

    On the Nucleo board you can use the 8 MHz, crystal based source, provided by the ST-LINK chip.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    hassan2
    hassan2Author
    Associate II
    December 11, 2015
    Posted on December 11, 2015 at 17:50

    Thanks for the replies.

    Sorry for such basic issues.

    I have played with the Arduino and I can send data back through the serial port form the Arduino to a serial port monitor on the system (computer). That is what I wanted to do.

    The VCP is connected to the ST-Link. It seems it cannot be used by the ST microcontroller (STM32F072) to send data or receive data from the system. 

    Tesla DeLorean
    Guru
    December 11, 2015
    Posted on December 11, 2015 at 18:22

    The VCP is connected to the ST-Link. It seems it cannot be used by the ST microcontroller (STM32F072) to send data or receive data from the system. 

     

    That seems at odds with my understanding of the situation...

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..