How to make STM32F103C8T6 (blue pill) USB CDC work properly
I have such dev board and try to run it as virtual com port. I created project cubemx, enable only usb as device in CDC mode. After generating and running project with next small fixes I run it on board.
int main(void)
{
//....skip
while (1)
{
/* USER CODE END WHILE */
const char* str = "Test\n";
CDC_Transmit_FS((uint8_t*)str, 5);
HAL_Delay(1000);
/* USER CODE BEGIN 3 */
}
gtkterm connects to the dev but no received and sent data.
When I started to debug interrupt handler I found that usb device always in USBD_STATE_DEFAULT mode since start and state isn't being changed instead of ISRs..
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
{
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->SOF != NULL)
{
pdev->pClass->SOF(pdev);
}
}
return USBD_OK;
}
I have read many tutorials and sample but the result is negative.
I have done USB CDC device successfully on STM32L476-DISCOVERY.
