Skip to main content
ДГори.1
Associate
January 19, 2021
Question

Stm32f105rct6 won't work USB VCP with CAN1+CAN2 together

I'm using Cube IDE 1.5.1 and stm32f105rct6 MCU.

I need to get data from CAN1 and CAN2 and send via USB VCP to terminal.

But I get "Unknown Device".

 MX_GPIO_Init();
 MX_CAN1_Init();
 MX_CAN2_Init();
 MX_USB_DEVICE_Init();

When I commented CAN Init:

 MX_GPIO_Init();
 //MX_CAN1_Init();
 //MX_CAN2_Init();
 MX_USB_DEVICE_Init();

My computer started USB connection and got Stm32 VCP device online.

How can I solve this problem?

This topic has been closed for replies.

3 replies

ДГори.1
Associate
January 19, 2021

My CAN1 is connected to PB8 and PB9. And USB_OTG_FS - to PA11 and PA12.

I tried remap CAN1

__HAL_RCC_AFIO_CLK_ENABLE();
__HAL_AFIO_REMAP_CAN1_2();

No effect...

ДГори.1
Associate
January 19, 2021

0693W000007BtGJQA0.jpg

/**
 * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
 * @note CASE 2: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (not available on 36-pin package)
 * @retval None
 */
#define __HAL_AFIO_REMAP_CAN1_2() AFIO_REMAP_PARTIAL(AFIO_MAPR_CAN_REMAP_REMAP2, AFIO_MAPR_CAN_REMAP)

"remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface" - why CubeIDE draw CAN1 at PB8 and PB9???

Amel NASRI
ST Technical Moderator
January 20, 2021

> Stm32f105rct6 won't work USB VCP with CAN1+CAN2 together

The explanation can be found in this article: Concurrent use of USB and CAN with STM32F103.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.