2021-08-30 10:20 PM
Hello,
I am currently trying to figure out, how to send continuos information via CAN.
When threre are only a few nodes Connected to the network, everything is fine, bus as soon as the overall busload is bigger than ~70% then the STM32 MCU stops transmitting.
I have already set up some filters, so the fastest messages do net get received by the MCU but I am still having the same problem.
However, I can still receive all the messages that are designed to go through the filters.
I also found out, that ~1/4 of the STM32f746g_Disco boards we have, do not allow CAN transmission at all. Receiving is no problem.
Setup:
STM32f746g_Disco, used as an information display in an automobile.
CAN Baudrate: 500kbit/s
7 CAN Filters are used.
The transmitting request gets started by a timer driven interrupt.
Code:
//TxHeader Setup
TxHeader1AE.DLC=8;
TxHeader1AE.IDE = CAN_ID_STD;
TxHeader1AE.StdId = 0x1AE;
//CAN Init
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 10;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_8TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;
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();
}
//CAN Tx Routing, Timer driven
void TIM1_UP_TIM10_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
/* USER CODE END TIM1_UP_TIM10_IRQn 0 */
HAL_TIM_IRQHandler(&htim10);
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
Data1AE[0] = xHeizungButton<<2;//(xHeizungButton<<2) + (xHeizungButton<<1);
Data1AE[0] = Data1AE[0] + (xLufterButton<<1);
HAL_CAN_AddTxMessage(&hcan1, &TxHeader1AE, Data1AE, &TxMailbox);
iCanCounter++;
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
}
//Variables
CAN_TxHeaderTypeDef TxHeader1AE;
CAN_RxHeaderTypeDef RxHeader;
uint8_t TxData[8];
uint8_t RxData[8];
uint32_t TxMailbox;
uint8_t Data1AE[8] ={0};
Do you have any ideas on how to solve this problem?
Thanks in advance!