cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F769I EVAL CAN problems

LDini.1
Associate II

Hello,

we are trying to listen to can messages with our evaluation board.

We are using a PCAN-USB adapter to play a can log to our eval board.

When starting the PC program it says that there is no can buffer detected. We assume that somehow our CAN Transceiver is not working or properly configured.

Following is our CAN1 initialization.

With this configuration we reach 500kbit/s baud rate at 216Mhz, which we are aiming for.

hcan1.Instance = CAN1;
  hcan1.Init.Prescaler = 27;
  hcan1.Init.Mode = CAN_MODE_SILENT;
  hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
  hcan1.Init.TimeSeg1 = CAN_BS1_1TQ;
  hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
  hcan1.Init.TimeTriggeredMode = DISABLE;
  hcan1.Init.AutoBusOff = DISABLE;
  hcan1.Init.AutoWakeUp = DISABLE;
  hcan1.Init.AutoRetransmission = DISABLE;
  hcan1.Init.ReceiveFifoLocked = DISABLE;
  hcan1.Init.TransmitFifoPriority = DISABLE;
  if (HAL_CAN_Init(&hcan1) != HAL_OK)
  {
    Error_Handler();
  }

Since we're trying to test the communication we have not yet configured an specific filter. We are aiming to receive all messages to make sure that the connection is established.

CAN_FilterTypeDef sFilterConfig;
 
  //Test-Filter passing all values through
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  sFilterConfig.FilterBank = 0;
  sFilterConfig.FilterIdHigh = 0x0000;
  sFilterConfig.FilterIdLow = 0x0000;
  sFilterConfig.FilterMaskIdHigh = 0x0000;
  sFilterConfig.FilterMaskIdLow = 0x0000;
 
  sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
  sFilterConfig.FilterActivation = ENABLE;
 
  //Filter setzen
  HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig);
  //Can Starten
  HAL_CAN_Start(&hcan1);
 
  	if (HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING)
  				!= HAL_OK) {
  			Error_Handler();
  		}
 
  	//NVIC Interrupts aktivieren
  	HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 1, 0);
  	HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);

Our GPIOs are configured in the .IOC

0693W00000YAt9sQAD.pngWe are expecting the HAL_CAN_RxFifo0MsgPendingCallback Method to be called after a Message is received an an Interrupt was thrown.

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
  can_datacheck = 1;
}

We configured our Jumper Positions following:

JP19 - 1 & 2 for high speed mode

JP18 fitted

JP14 fitted

Is there anything we are missing out on ?

We can not figure out our problem.

Thank you very much for any help,

regards Luis

3 REPLIES 3
Javier1
Principal

Not saying thats your problem but i do it in this order.(different mcu but maybe it helps you)

 0693W00000YAudFQAT.png0693W00000YAuc7QAD.pngAnd the

HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 1, 0);

HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);

part

Is already deatl by cubeMX when i tick the interruption generation button.

0693W00000YAucqQAD.png

we dont need to firmware by ourselves, lets talk
LDini.1
Associate II

Thank you a lot for your answer.

Somehow i managed to get it running.

Did not change anything.

Thats even worse than having it not working at all

we dont need to firmware by ourselves, lets talk