cancel
Showing results for 
Search instead for 
Did you mean: 

Transmit CAN frames with HAL Driver not working on a STM32F207

TCest
Associate

I wanted to send and receive a message via CAN2 of a STM32F207 Unit, but sending always reported errors.

But when I change the following lines in the HAL Driver it works and the receiver gets the CAN frames corretly.

Why is the TDTR of the mailbox not cleared or at least somehow configurable?

I needed to change these lines (in HAL_CAN_transmit and HAL_CAN_transmit_IT)

hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= (uint32_t)0xFFFFFFF0U;
hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC;

to

hcan->Instance->sTxMailBox[transmitmailbox].TDTR = hcan->pTxMsg->DLC;

I can't configure the timestamp feature anywhere via the driver but when the TDTR register is not zeroed (except the DLC value) transmit is not working.

I don't want to have changes in the HAL driver as updating the driver is then always a problem ... Any hints how this can be done?

Cheers

Thilo

1 REPLY 1
TCest
Associate

Sorry but the problem wasn't that register!

It were the time quanta in bit segment settings.

I'm new to CAN so I currently have no idea what this is about but for me it needed to be set to:

Prescalar = 24

Time Quanta in Bit Segment 1 = 13 Times

Time Quanta in Bit Segment 2 = 2 Times

If anyone can explain what this is about, would be great!

Another thing I figured is, that as I use CAN2 of my STM32F207, I need to use Banknumber 0 for my one filter.

filter.FilterNumber = 0;
filter.FilterMode = CAN_FILTERMODE_IDMASK;
filter.FilterScale = CAN_FILTERSCALE_16BIT;
filter.FilterIdHigh = 0;
filter.FilterIdLow = 0;
filter.FilterMaskIdHigh = 0;
filter.FilterMaskIdLow = 0;
filter.FilterFIFOAssignment = CAN_FILTER_FIFO0;
filter.FilterActivation = ENABLE;
filter.BankNumber = 0;

When I use 14 as Banknumber which is the default of the register it is written to later, it doesn't match at all.

Cheers,

Thilo