FDCAN peripheral sends only partial CAN frame with no data

170 Views Asked by At

I'm trying to get the FDCAN peripheral (on an stm32h750) to talk on a standard 1mbps CAN network. I'm sending a test message, defined here:

FDCAN_TxHeaderTypeDef txheader;

txheader.Identifier = 69;

txheader.IdType = FDCAN_STANDARD_ID;
txheader.TxFrameType = FDCAN_DATA_FRAME;

txheader.DataLength = FDCAN_DLC_BYTES_8;
txheader.BitRateSwitch = FDCAN_BRS_OFF;
txheader.FDFormat = FDCAN_CLASSIC_CAN;
txheader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
txheader.MessageMarker = 0;

testdata[0] = 'b';
testdata[1] = 'l';
testdata[2] = 'a';
testdata[3] = 'r';
testdata[4] = 'g';
testdata[5] = 'f';
testdata[6] = 'o';
testdata[7] = 'o';
HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &txheader, testdata);

and I've attached a logic analyzer capture of the bus to show the result. logic analyzer capture

Any thoughts on where to look? I'm not sure what could cause this symptom. The peripheral appears to be able to read to an existing (correctly formatted frame)

Here is my fdcan initialization code:

  hfdcan1.Instance = FDCAN1;
  hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
  hfdcan1.Init.AutoRetransmission = ENABLE;
  hfdcan1.Init.TransmitPause = DISABLE;
  hfdcan1.Init.ProtocolException = DISABLE;
  hfdcan1.Init.NominalPrescaler = 20;
  hfdcan1.Init.NominalSyncJumpWidth = 1;
  hfdcan1.Init.NominalTimeSeg1 = 5;
  hfdcan1.Init.NominalTimeSeg2 = 4;
  hfdcan1.Init.DataPrescaler = 20;
  hfdcan1.Init.DataSyncJumpWidth = 1;
  hfdcan1.Init.DataTimeSeg1 = 5;
  hfdcan1.Init.DataTimeSeg2 = 4;
  hfdcan1.Init.MessageRAMOffset     = 0;
  hfdcan1.Init.StdFiltersNbr        = 1;
  hfdcan1.Init.ExtFiltersNbr        = 0;
  hfdcan1.Init.RxFifo0ElmtsNbr      = 2;
  hfdcan1.Init.RxFifo0ElmtSize      = FDCAN_DATA_BYTES_64;
  hfdcan1.Init.RxFifo1ElmtsNbr      = 0;
  hfdcan1.Init.RxBuffersNbr         = 64;
  hfdcan1.Init.TxEventsNbr          = 0;
  hfdcan1.Init.TxBuffersNbr         = 64;
  hfdcan1.Init.TxFifoQueueElmtsNbr  = 2;
  hfdcan1.Init.TxFifoQueueMode      = FDCAN_TX_FIFO_OPERATION;
  hfdcan1.Init.TxElmtSize           = FDCAN_DATA_BYTES_64;
  if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
  {
    Error_Handler();
  }

I have tried: -messing with DLC to be the number 8 instead of FDCAN_DLC_BYTES_8 which expands to 0x00080000U as well as FDCAN_DATA_BYTES_8 which expands to 4.

1

There are 1 best solutions below

1
ethan On

I fixed this by making FDCAN_TxHeaderTypeDef txheader; global rather than a local variable.