USB issue STM32F0x with CDC
Hi,
I�m newbie in USB projects with STM32, so I kindly ask your help to find what I�m doing wrong with STM32F072 and CDC USB.
For now, I�m trying to send some chars through USB form microcontroller to USB PC with �CDC_Transmit_FS(string,8);� command.
The problem is that if I send more that 8 bytes at the same time (same command), then I receive garbage chars on host.
If I send 8 or less, seems to work fine.
Here is my code of �CDC_Transmit_FS� routine:
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 8 */
uint16_t i;
for(i=0;i<Len;i++)
{
UserTxBufferFS[i]=Buf[i];
}
USB_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
/* USER CODE END 8 */
return result;
}
I have checked (as far as I know) till : �HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)� and it seems that pointer of buffer is pointing to right data (no garbage)
Am I doing something wrong? Something missed?
My version files of CubeMX are:
* @file : usbd_conf.c
* @date : 09/12/2014 10:39:27
* @version : v1.0_Cube
* @file : USB_DEVICE
* @date : 09/12/2014 10:39:27
* @version : v1.0_Cube
* @file : usbd_conf.c
* @date : 09/12/2014 10:39:27
* @version : v1.0_Cube
* @file usbd_cdc.c
* @version V2.2.0
* @date 13-June-2014
* @file : usbd_cdc_if.c
* @version : V1.1.0
* @date : 19-March-2012
* @file usbd_core.c
* @version V2.2.0
* @date 13-June-2014
Any help will be appreciated.
Thanks in advance,
Best regards.
Jai
#stm32f0-usb-cdc-library