cancel
Showing results for 
Search instead for 
Did you mean: 

Why can't I enable USB and CAN simultaneously using STM32CubeMX?

maggie
Associate III
Posted on July 31, 2014 at 16:55

I'm using STM32CubeMX v4.3 to generate my STM32F303x custom board pins.

I need both USB and CAN enabled.

I can set USB (as FS Device) pins as:

  • PA11: USB_DM
  • PA12: USB_DP
And CAN pins as:

  • PD0: CAN_RX
  • PD1: CAN_TX

But for some reason, I can't enable USB and CAN at the same time.

When I try to enable USB, CAN can't be enabled anymore (grayed-out) and on mouse hover, says:

  • ''CAN Not Available: CAN IP can be selected if USB IP is not selected''

When I try to enable CAN, USB can't be enabled anymore (grayed-out) and on mouse hover, says:

  • ''USB Not Available: USB IP can be selected if CAN IP is not selected''

Why?

Anything I'm missing here?

#stm32cubemx-usb-can
4 REPLIES 4
Posted on July 31, 2014 at 17:58

Why? Anything I'm missing here?

In the original F1 design CAN and USB shared a common 512 byte SRAM buffer, this is supposedly not the case with the F303 design, but the logic in CubeMX might still be blocking this option.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kormoczi
Associate II
Posted on August 08, 2014 at 18:55

Same situation here, can't enable the CAN while USB is enabled.

Can anybody tell me when will be this bug fixed?

I am in the middle of a new design based on STM32F303x MCU with Cube...

Best regards!

maggie
Associate III
Posted on August 12, 2014 at 11:48

Not sure when the bug will be fixed, no response in the bug report I filed

/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Bug%20Report%20STM32CubeMX%20v4.3%2c%20can%27t%20enable%20USB%20and%20CAN%20at%20the%20same%20time%20for%20STM32F303x&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=16

. Anyway, what I did as a workaround was to manually set USB pins (PA11, PA12) and CAN (PD0, PD1) pins by clicking on them on the Pinout (right frame), before enabling them on the Pinout (left frame). After that I chose to enable USB than CAN inPinout (left frame). Then I added these lines in main.c:

// Private variables
+CAN_HandleTypeDef hcan;
// Private function prototypes
+static void MX_CAN_Init(void);
// main()
+ MX_CAN_Init();
// Actual CAN init func 
/* CAN init function */
+void MX_CAN_Init(void)
+{
+
+ hcan.Instance = CAN;
+ hcan.Init.Prescaler = 16;
+ hcan.Init.Mode = CAN_MODE_NORMAL;
+ hcan.Init.SJW = CAN_SJW_1TQ;
+ hcan.Init.BS1 = CAN_BS1_1TQ;
+ hcan.Init.BS2 = CAN_BS2_1TQ;
+ hcan.Init.TTCM = DISABLE;
+ hcan.Init.ABOM = DISABLE;
+ hcan.Init.AWUM = DISABLE;
+ hcan.Init.NART = DISABLE;
+ hcan.Init.RFLM = DISABLE;
+ hcan.Init.TXFP = DISABLE;
+ HAL_CAN_Init(&hcan);
+}

> I am in the middle of a new design based on STM32F303x MCU with Cube... Great, same case as I am. Let's help each other then! :-)