cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1RE FDCAN normal / external loopback issue

lr2
Associate

Hi everyone,

I am currently experiencing some issues with the FDCAN interface; my setup consists of two nucleo boards (Nucleo-G0B1RE) which use FDCAN interface to communicate with each other. As transceivers I am using two ATA6563-click boards.

The clock used for FDCAN interface is PLLQ which ticks at 32MHz. The FDCAN parameters were configured using kvaser canfd timing calculator; Filters are disabled.

I’ve generated two set of parameters:

  1. Nominal bitrate 500 kBit/s; Data bitrate: 2MBit/s 0693W00000aHcAbQAK.png
  2. Nominal bitrate 500 kBit/s; Data bitrate: 4MBit/s 0693W00000aHcAqQAK.png

In both scenarios I’ve used a payload of 12 bytes and preserved the sending header:

txh_n1.Identifier = 0x1ad;
  txh_n1.IdType = FDCAN_STANDARD_ID;
  txh_n1.TxFrameType = FDCAN_DATA_FRAME;
  txh_n1.DataLength = FDCAN_DLC_BYTES_12;
  txh_n1.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
  txh_n1.BitRateSwitch = FDCAN_BRS_ON;
  txh_n1.FDFormat = FDCAN_FD_CAN;
  txh_n1.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
  txh_n1.MessageMarker = 0x0;

and the same while loop:

bool is_different = 0;
 
  HAL_UART_Transmit(&huart2, (uint8_t *)"Start...\r\n", 10, 100);
  HAL_FDCAN_EnableTxDelayCompensation(&hfdcan1);
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
#if TX_NODE
    //running on the transmitter board
    if(HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &txh_n1, tx_node1) != HAL_OK) {
      Error_Handler();
    } else {
      HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
    }
    HAL_Delay(50); 
#else
    //running on the receiving board
    is_different = false;
    memset(&rx_node1, 0, 12 * sizeof(uint8_t));
 
    if(HAL_FDCAN_GetRxMessage(&hfdcan1, FDCAN_RX_FIFO0, &rxh_n1, rx_node1) == HAL_OK) {
      for(uint8_t idx = 0; idx < 12 && !is_different; idx++) {
        if(rx_node1[idx] != tx_node1[idx])
          is_different = true;
      }
 
      if(!is_different) {
        HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
        HAL_UART_Transmit(&huart2, (uint8_t *)"OK\r\n", 4, 100);
      } else {
        HAL_UART_Transmit(&huart2, (uint8_t *)"BAD\r\n", 5, 100);
      }
    }
 
    HAL_Delay(10);
#endif
     /* USER CODE END WHILE */
    /* USER CODE BEGIN 3 */
  }

Now, I am facing the following issue. In the first scenario everything works as intended. I receive all the transmitted data.

In the second one (where the bitrate is 4Mbit/s) with the transmitter in normal mode, the receiver node doesn’t receive anything. Switching the transmitter to external loopback, the receiver node receives all the data, as seen in the following images:

4Mbit normal mode

0693W00000aHcC3QAK.jpg4Mbit External loopback mode:0693W00000aHcAmQAK.jpg4Mbit bit timing0693W00000aHcCNQA0.jpgAll of the oscope images are taken on the receiver side on PC4 and PC5 pins.

At 2Mbits everything works as intended. Changing from 2 to 3 or 4 Mbits in normal mode the transmitting board stops transmitting data after arbitration. Switching to external loopback, all the data arrives on the receiver node.

Does someone know what is happening there, why it happens and how can it be solved?

Regards,

Liviu

0 REPLIES 0