2016-10-24 07:41 AM
Hi Guys,
i try to experiment a bit with the USB CDC library. Sadly I don't get it to work out of the box after I configured everything in STMCubeMX.I tried to learn something from the F4 firmware libraray tutorial projects on CDC. But I find it quite complicated to understand, since there's a complete different board used and also an USART used for communicating.Basically I want to configure my STM446RE to behave as a USB CDC device with messages send over parallel port as a VCP device. But when I run the program Windows doesn't recognize my new device. Just the one created by the STV/Link debugger.To send data over USB I added a message which I send in main while(1) loop:/* USER CODE BEGIN 0 */uint8_t HiMsg[] = ''hello HHI\r\n'';/* USER CODE END 0 */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(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_TIM3_Init(); MX_TIM2_Init(); MX_USB_DEVICE_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { CDC_Transmit_FS(HiMsg, strlen(HiMsg)); HAL_Delay(500); } /* USER CODE END 3 */}Would be glad if someone could help.Thanks! #stm32446re-nucleo2016-10-24 08:02 AM
From: brammer.benjaminPosted: Monday, October 24, 2016 4:41 PMSubject: STM32446RE Nucleo as a USB CDC device
Hi Guys,
i try to experiment a bit with the USB CDC library. Sadly I don't get it to work out of the box after I configured everything in STMCubeMX.I tried to learn something from the F4 firmware libraray tutorial projects on CDC. But I find it quite complicated to understand, since there's a complete different board used and also an USART used for communicating.Basically I want to configure my STM446RE to behave as a USB CDC device with messages send over parallel port as a VCP device. But when I run the program Windows doesn't recognize my new device. Just the one created by the STV/Link debugger.To send data over USB I added a message which I send in main while(1) loop:/* USER CODE BEGIN 0 */uint8_t HiMsg[] = ''hello HHI\r\n'';/* USER CODE END 0 */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(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_TIM3_Init(); MX_TIM2_Init(); MX_USB_DEVICE_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { CDC_Transmit_FS(HiMsg, strlen(HiMsg)); HAL_Delay(500); } /* USER CODE END 3 */}Would be glad if someone could help.Thanks!2016-10-24 08:20 AM
Perfect! I managed it on my own. I forgot to write the apropriate CDC_Control_FS() routines. The CDC_SET_LINE_CODING case and the CDC_GET_LINE_CODING.
Now it works.