cancel
Showing results for 
Search instead for 
Did you mean: 

How to make use of "Normal Mode" available in bxCAN(STM32L476RG Nucleo Board)?

RahulR
Associate II

I can able to do "Loopback Mode" and I'm getting the desired output signal(CAN_TX). When I opted "Normal Mode" I can not see any output signal at TX pin.

Here I have selected polling method only and not used any of the interrupt(eg:CAN1_RX0,TX Interrupt). My "BIT Timing Parameters" and LoopBack Output are as shown in the image.

For the better understanding I am adding my code along with this post.

What may be reason? Can anyone please help me?

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);

 }

}

0693W000006FxpgQAC.bmp 

0693W000006FxoTQAS.jpg 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

To be able to use the CAN module in normal mode you have to use a CAN transceiver + termination resistors and connect this node to another node via CAN bus to transceive CAN messages. Please check STM32L476G-EVAL for HW reference.

NUCLEO boards as they are CAN module can be used only in Loopback mode.

STM32

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
SofLit
ST Employee

Hello,

To be able to use the CAN module in normal mode you have to use a CAN transceiver + termination resistors and connect this node to another node via CAN bus to transceive CAN messages. Please check STM32L476G-EVAL for HW reference.

NUCLEO boards as they are CAN module can be used only in Loopback mode.

STM32

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.