2024-07-16 12:11 PM - last edited on 2024-07-16 12:22 PM by SofLit
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
2024-07-16 12:18 PM - edited 2024-07-17 05:58 AM
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.
2024-07-16 12:25 PM
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.
2024-07-16 12:43 PM - edited 2024-07-16 12:49 PM
What do you mean by "Flow Control Frame" ? RTR frame (Remote Transmission Request)?
2024-07-16 01:47 PM
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);
2024-07-16 08:06 PM
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:
For Refence i have attached on image as well
2024-07-17 01:39 AM
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).