cancel
Showing results for 
Search instead for 
Did you mean: 

Quick clarification of USB CDC buffer sizes when used with CAN on F072

MattKefford
Associate III

Hi all!

I intend to use USB and CAN on an STM32F072. The datasheet describes a 1KB SRAM buffer, 768B for USB and 256B for CAN.

In CubeMX, when I set up the USB as a VCP, by default it sets 1000 bytes for "USB CDC Tx Buffer Size" and 1000 bytes for "USB CDC Rx Buffer Size". In code these translate to defining APP_RX_DATA_SIZE/APP_TX_DATA_SIZE which are used to create two arrays, so I can't see how these are linked to the dedicated SRAM, but I want to be sure.

Firstly I'd like to clarify, are these two arrays supposed to correspond to the SRAM buffer? If so, shouldn't they be max 512B each and is there a risk of over loading the SRAM buffer by making these arrays too large?

Moreover, when I also set up CAN in CubeMX, these USB buffers do not change and the CAN buffer is non-configurable, do I need to account for the CAN buffer by reducing my USB buffers to 384B each?

Thanks for taking the time to read my question :) any help is appreciated.

3 REPLIES 3

I don't think anybody here is going to perform an in-depth review of the Cube code for you, so it is probably up to you. An obvious place to start might be the mapfile, to find out where are those buffers allocated.

JW

MattKefford
Associate III

[removed]

No of course not, and I wouldn't expect anybody to, but someone who has some experience with USB may know the answer off the top of their head.

My question isn't so much about the cube code but more about the hardware capabilities and avoiding any pitfalls with USB buffer overflows.

I will take a look for this map file you speak of.