2020-01-10 07:48 AM
hello, i starting a project in STM32F103C8T6 bluepill.
it's my first project on STM32.
configure my hight resonator, usb + cdc + debug, like all the video on youtube.
but for my not works.
my hardware is correct R10=1.5KO, enumeration was good. COM29.
but i cannot write and read.
no breakpoint in CDC_Receive_FS()
if i calling CDC_Transmit_FS on main , return BUSY.
increase heap 0x800 KO
increase stack 0x800 KO
set line CODING KO
/* USER CODE BEGIN PRIVATE_DEFINES */
/* Define size for the receive and transmit buffer over CDC */
/* It's up to user to redefine and/or remove those define */
#define APP_RX_DATA_SIZE 64
#define APP_TX_DATA_SIZE 64
case CDC_SET_LINE_CODING:
LineCoding.bitrate = (uint32_t) (pbuf[0] | (pbuf[1] << 8) |
(pbuf[2] << 16) | (pbuf[3] << 24));
LineCoding.format = pbuf[4];
LineCoding.paritytype = pbuf[5];
LineCoding.datatype = pbuf[6];
/* Set the new configuration */
//ComPort_Config();
break;
case CDC_GET_LINE_CODING:
pbuf[0] = (uint8_t) (LineCoding.bitrate);
pbuf[1] = (uint8_t) (LineCoding.bitrate >> 8);
pbuf[2] = (uint8_t) (LineCoding.bitrate >> 16);
pbuf[3] = (uint8_t) (LineCoding.bitrate >> 24);
pbuf[4] = LineCoding.format;
pbuf[5] = LineCoding.paritytype;
pbuf[6] = LineCoding.datatype;
break;
i 'm continuing my search but if you want help me?
i'm crazy!
thanks
2020-01-10 08:53 PM
What you have did in main for cdc configuration.
i think you have problem in pin hardware configuration beacause cdc is so much easy to configure
you just have to initalize
MX_USB_DEVICE_Init(); // if you are using stmcubemx ide
and just to call functin which you have passed is CDC_Transmit_FS or CDC_Transmit_HS if you have used high speed mode
All the best
2020-01-11 02:19 PM
my hardware is good, because the cdc was detected.
in cube mx, one led for have un cycle information.
default configuration cube mx.
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
HAL_Delay(5000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
uint8_t l_buffer[5]="toto";
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
CDC_Transmit_FS(l_buffer,sizeof(l_buffer));
HAL_Delay(2000);
}
/* USER CODE END 3 */
}
2020-01-11 02:25 PM
with cubeMx cdc generate for STM32F1 no works.....
the example in project is very different
arf...
thanks
2020-01-12 08:38 PM
your firmware is looking seens to be ok and nothing issue with that
try two things
1. if you have active VBUS then please disable in your hardware configuration file
2.if above things doesn't work then try use high spped mode & use hs function because for mostly for fs mode you have to make some hardware changes
Best of luck
2020-01-17 09:33 PM
have you solved out problem?
2020-01-20 02:29 AM
In the example cubeMx, USB cable must be plug after started.
if the cable is already pluged at start, example don't works.
and i have pin PB9 configured in output for works.
i don't have schematic of my bluepill. lot of schematic on the web..
thanks
2020-01-20 03:56 AM
that is not ok , it works all time once you load firmware in controller ,
you must have issue with VBUS pin , just confifure without use of vbus pin