AnsweredAssumed Answered

STM32F072-Discovery Virtual Com Problem

Question asked by olejnik.pawel on Dec 25, 2015
Latest reply on Dec 26, 2015 by Clive One
Hi, I've been struggling to make a working program, that would allow my board to communicate with the computer. So far I reviewed a lot of examples but I still have problems to do so. I managed to connect the device, it is recognised as Virtual COM and I successfully connected through a terminal. However, I am unable to send anything. I tried using the function:
static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len)
{
    uint32_t i = 0;
    //
    while(i < Len)
    {   //
        APP_Rx_Buffer[APP_Rx_ptr_in] = *(Buf + i);
        APP_Rx_ptr_in++;
        i++;
        /* To avoid buffer overflow */
        if(APP_Rx_ptr_in == APP_RX_DATA_SIZE)
        {
            APP_Rx_ptr_in = 0;
        }
    }
    return USBD_OK;

Along with:

void VCP_send_str(uint8_t* buf)
{
    uint32_t i = 0;
    //
    while(*(buf + i))
    {
        i++;
    }
    VCP_DataTx(buf, i);
}

Now what I understand is I have to pass a buffor to the VCP_send_str and I do that this way in my main:

int main(void)
{
    uint8_t Buffer[8];
    int counter=0;
     
    Buffer[0] = 't';
    Buffer[1] = 'e';
    Buffer[2] = 's';
    Buffer[3] = 't';
    Buffer[4] = 'i';
    Buffer[5] = 'n';
    Buffer[6] = 'g';
    Buffer[7] = '.';
     
     
  USBD_Init(&USB_Device_dev,
            &USR_desc,
            &USBD_CDC_cb,
            &USR_cb);
     
     
 
  while (1)
  {
        if (counter>=1000){
            counter=0;
        }
        if (counter%100==0){
            VCP_send_str(Buffer);
        }
    counter++;
  }
}

I can provide more code if needed, any help would be appreciated.

Outcomes