cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to send 64 bytes of data in the form of Multi frame in CAN FD

vividhadhengre
Associate II

 

I am trying to find out whether is it possible to send 64bytes of data in one frame of Multiframe in CAN FD.

i.e First frame will have 64 bytes, Consecutive frame will also have 64 bytes in STM32G0B1KBU6 basically in G0 series MCU

6 REPLIES 6
SofLit
ST Employee

Hello,

Not sure what do you mean by "one frame of Multiframe in CAN FD".

Do you mean you need to send a frame more than 64 bytes and the FDCAN peripheral will split them in 64 byte chunks and send them successively?

If this what you mean, the user needs to do it on his own by software as the FDCAN cell doesn't manage natively this kind of operation. 

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

Hello, Yes actually as per Multiframe concept in CAN 2.0B , we send a first frame with 8 data bytes and wait for FLow control frame(0 byte) and then we send the consecutive frame with data size of 8bytes like this it goes on until the last frame is reached.

In similar way for CAN FD , is it possible to send 64bytes of data in one first frame then wait for Flow Control Frame, then again send the 64bytes of data until the last data frame is reached.

What do you mean by "Flow Control Frame" ? RTR frame (Remote Transmission Request)?

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

You have to do it in the FW to send multiple frames. You'll need to use the first byte as a frame indicator. So technically you'll be sending 1 + 63 bytes, where the first byte is frame information and 63 bytes of data.

Create a data structure like this. This is just a reference so you can do it how you like.

 

enum
{
	FIRST_FRAME,
	MORE_FRAMES,
	LAST_FRAME
};

typedef union
{
	struct
	{
		uint8_t data[64];
	}Bytes;
	struct
	{
		unsigned firstFrameActive:2; // 0=firstFrame, 1=moreFrames, 2=lastFrame
		unsigned frameSequenceNumber:6; // 0-63 frames
		uint8_t data[63];
	}Status;
}DataPacket_t;

 

 

Create the canData variable. Populate the data accordingly and just send the packet. This is just a reference showing how the sequence of frames would be sent. I'm not check HAL status here. You'll have to come up with you own packet stuffing using a forloop or whatever method and to be sure a frame has been sent before continuing with the rest of the packets. 

 

		DataPacket_t canData = {0};

		// first packet
		canData.Status.firstFrameActive = FIRST_FRAME;
		canData.Status.frameSequenceNumber = 0;
		canData.Status.data[0] = 0x01; // user will need to fill the rest of the array with data.

		// update pTxHeader to send 64 bytes
		HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &pTxHeader,  canData.Bytes.data);

		// next packet
		canData.Status.firstFrameActive = MORE_FRAMES;
		canData.Status.frameSequenceNumber = 1;
		canData.Status.data[0] = 0x01; // user will need to fill the rest of the array with data.

		HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &pTxHeader,  canData.Bytes.data);

		// last packet
		canData.Status.firstFrameActive = LAST_FRAME;
		canData.Status.frameSequenceNumber = 2;
		canData.Status.data[0] = 0x01; // user will need to fill the rest of the array with data.

		// update pTxHeader if less than 64 bytes
		HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &pTxHeader,  canData.Bytes.data);

 

 

 

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.

Different Types of Frames in CAN-TP (ISO 15765)
So to make it possible, the CAN-TP also having 2 types of frames.
Single Frame and Multi-Frame.
Again the Multi-frame is having 3 types of frames. So total 4-types frames are there in CAN-TP:

  1. Single Frame (0x0).
  2. Multi-Frame.
    • First Frame (0x1).
    • Consecutive Frame (0x2).
    • Flow Control Frame (0x3).

For Refence i have attached on image as well

Hello @vividhadhengre ,

As stated previously, this is managed by software (application layer: the 7th layer of OSI model) not at the CAN protocol level (link layer). 

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