cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the working condition of the CAN Transceiver?

RahulR
Associate II

0693W000006FeLdQAK.bmp0693W000006FeLXQA0.jpgRecently I bought a CAN Transceiver(SN65HVD230 CAN Board Network Transceiver Evaluation Development Module) to convert CAN_RX, CAN_RX signals into CAN_H, CAN_L from a STM32L476RG Nucleo board.

How can I check this Transceiver, whether it is working or not? Which mode I should use(eg: Loopback, Normal.. etc)?

I tried to connect the CAN_TX,RX terminal directly to Transceiver input and checked the CAN_H,L terminal by using a DSO. I am not getting the differential signal as output. When I select Loopback mode,I am able to see the signle ended output through the DSO. I have added the signal image along with this. 

Can anyone help me?

2 REPLIES 2
KnarfB
Principal III

There should be a terminating R on the CAN bus side. For testing, you may set all "Basic Parameters" to disable or like that:

0693W000006FgEOQA0.pngand you should see the waveforms:

0693W000006FgByQAK.pngI'm using MCP2551 though.

RahulR
Associate II

As you said I connected a resister across the CAN_H, CAN_L. Even though I am not getting the output.

I was getting proper otput when I am using Loopback mode. Once I changed the mode to Normal Mode data reception is not happening. 

I came to know this throgh the debugging window. I did not use any Interrupt( Eg; CAN1_RX0_Interrpt), only used polling method.

I have added my code and BIT timing parameter as follows as follows. 

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_CAN1_Init();

 /* USER CODE BEGIN 2 */

 sFilterConfig.FilterBank = 0;

 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;

 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;

 sFilterConfig.FilterIdHigh = 0x0000;

 sFilterConfig.FilterIdLow = 0x0000;

 sFilterConfig.FilterMaskIdHigh = 0x0000;

 sFilterConfig.FilterMaskIdLow = 0x0000;

 sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;

 sFilterConfig.FilterActivation = ENABLE;

 sFilterConfig.SlaveStartFilterBank = 14;

 if((HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig)) != HAL_OK)

 {

 Error_Handler();

 }

 else

 {

 t1=1;

 }

 if(HAL_CAN_Start(&hcan1) != HAL_OK)

 {

 Error_Handler();

 }

 else

 {

 t2=1;

 }

 if((HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_TX_MAILBOX_EMPTY)) != HAL_OK)

 {

Error_Handler();

 }

 else

 {

 t3=1;

 }

 TxMessage.StdId = 0x321;

 TxMessage.ExtId = 0x01;

 TxMessage.RTR  = CAN_RTR_DATA;

 TxMessage.IDE  = CAN_ID_STD;

 TxMessage.DLC  = 8;

 TxMessage.TransmitGlobalTime = DISABLE;

 TxData[0] = 1;

 TxData[1] = 2;

 TxData[2] = 3;

 TxData[3] = 4;

 TxData[4] = 5;

 TxData[5] = 6;

 TxData[6] = 7;

 TxData[7] = 8;

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 HAL_CAN_AddTxMessage(&hcan1, &TxMessage, TxData, &TxMailbox);

 HAL_Delay(500);

 TxData[7] = TxData[7] + 1;

 t4 = HAL_CAN_GetTxMailboxesFreeLevel(&hcan1);

//

 t5 = HAL_CAN_GetRxFifoFillLevel(&hcan1, CAN_RX_FIFO0);

 HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &RxMessage, RxData);

 HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

 }0693W000006Fo3YQAS.jpg 

Can you please help me?