cancel
Showing results for 
Search instead for 
Did you mean: 

CAN-BUS normal mode is not working, but loopback mode works fine using CAN Isolator click module (ADM3053)

DKuro.1
Associate III

Hi,

I am using two STM32F103 Nucleo boards and STM32CubeIDE.

I can see in the oscilloscope the Tx sinal outputs some data when the mode is configured as loopback. But when I switch the mode to normal I can see in the oscilloscope only a short low level pulse and then the channel returns to high level.

Why is this happening?

How can I configure the CAN to work in normal mode?

The first code block is the configuration and the second is the call to transmitt

  hcan.Instance = CAN1;
  hcan.Init.Prescaler = 16;
  hcan.Init.Mode = CAN_MODE_NORMAL;
  hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
  hcan.Init.TimeSeg1 = CAN_BS1_12TQ;
  hcan.Init.TimeSeg2 = CAN_BS2_4TQ;
  hcan.Init.TimeTriggeredMode = DISABLE;
  hcan.Init.AutoBusOff = DISABLE;
  hcan.Init.AutoWakeUp = DISABLE;
  hcan.Init.AutoRetransmission = DISABLE;
  hcan.Init.ReceiveFifoLocked = DISABLE;
  hcan.Init.TransmitFifoPriority = DISABLE;
  if (HAL_CAN_Init(&hcan) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN CAN_Init 2 */
	TxHeader.StdId = 0x245;
	TxHeader.DLC = 1;
	TxHeader.ExtId = 0;
	TxHeader.IDE = CAN_ID_STD;
	TxHeader.RTR = CAN_RTR_DATA;
	TxHeader.TransmitGlobalTime = DISABLE;
 
 
 
	//filter one (stack light blink)
	sFilterConfig.FilterFIFOAssignment=CAN_FILTER_FIFO0; //set fifo assignment
	sFilterConfig.FilterIdHigh=0x245<<5; //the ID that the filter looks for (switch this for the other microcontroller)
	sFilterConfig.FilterIdLow=0;
	sFilterConfig.FilterMaskIdHigh=0;
	sFilterConfig.FilterMaskIdLow=0;
	sFilterConfig.FilterScale=CAN_FILTERSCALE_32BIT; //set filter scale
	sFilterConfig.FilterBank = 0;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
	sFilterConfig.FilterActivation=ENABLE;
 
	HAL_CAN_ConfigFilter(&hcan, &sFilterConfig); //configure CAN filter
 
	HAL_CAN_Start(&hcan); //start CAN
	HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING); //enable interrupts
		  if (HAL_CAN_AddTxMessage(&hcan, &TxHeader, CAN_tx_array, (uint32_t*)&mail_box) != HAL_OK)
		  {
		    Error_Handler();
		  }

Thanks!!

Daniel

1 REPLY 1
DKuro.1
Associate III

Solved... The CAN Isolator needs 5V and 3.3V but its not showed anywhere.

Also the pin Tx of the board is connected to the Rx of the ADM3053, so fro the ST board is needed to connect the CAN_Tx to the Rx of the CAN Isolator Click (which is connected to the Tx of the ADM3053). 😅