cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Messages not sending

DBles.1
Associate II

Hi, I am using the following:

cubeIDE 1.13.1/STM32F072C8U6/baud = 250K - I attached a picture of my clock diagram & param setup.

Hi, I am using the following:

cubeIDE 1.13.1/STM32F072C8U6/baud = 250K - I attached a picture of my clock diagram & param setup.

I do not see messages sending on the CAN bus. They worked fine in my previous IDE. I have a feeling it has to due with the time quanta but not 100% sure. I tried adjusting to quanta 10/5 after reading the following with no luck:

http://www.bittiming.can-wiki.info/ 

Init:

static void MX_CAN_Init(void)

{

 

/* USER CODE BEGIN CAN_Init 0 */

 

/* USER CODE END CAN_Init 0 */

 

/* USER CODE BEGIN CAN_Init 1 */

 

/* USER CODE END CAN_Init 1 */

hcan.Instance = CAN;

hcan.Init.Prescaler = 32;

hcan.Init.Mode = CAN_MODE_NORMAL;

hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;

hcan.Init.TimeSeg1 = CAN_BS1_1TQ;

hcan.Init.TimeSeg2 = CAN_BS2_1TQ;

hcan.Init.TimeTriggeredMode = DISABLE;

hcan.Init.AutoBusOff = DISABLE;

hcan.Init.AutoWakeUp = DISABLE;

hcan.Init.AutoRetransmission = DISABLE;

hcan.Init.ReceiveFifoLocked = DISABLE;

hcan.Init.TransmitFifoPriority = DISABLE;

if (HAL_CAN_Init(&hcan) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN CAN_Init 2 */

// Example: extended ID = 0x18FF51D0 (29 bits) matching with bits [31:3] in the filter register

// For bit position, please refer to document RM0008 (STM32F10x reference manual, page 657)

// FILTER register = 0b1100 0111 1111 1010 1000 1110 1000 0100

sf_typedef.FilterMaskIdHigh = 0xC7FA;

sf_typedef.FilterMaskIdLow = 0x8E84;

sf_typedef.FilterFIFOAssignment = CAN_FILTER_FIFO0;

sf_typedef.FilterBank = 0;

sf_typedef.FilterMode = CAN_FILTERMODE_IDMASK;

sf_typedef.FilterScale = CAN_FILTERSCALE_32BIT;

sf_typedef.FilterMaskIdHigh = 0x07FF; // Setup ID Mask to only look for "FF5x" in the PGN

sf_typedef.FilterMaskIdLow = 0x8004; // Set IDE bit to make sure no standard ID message goes through filter

sf_typedef.FilterActivation = CAN_FILTER_ENABLE;

if (HAL_CAN_ConfigFilter(&hcan, &sf_typedef) != HAL_OK)

Error_Handler();

 

//Start CAN Peripheral

if (HAL_CAN_Start(&hcan) != HAL_OK)

{

/* Start Error */

Error_Handler();

}

 

//Start rx ISR operation

if (HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)

{

/* Notification Error */

Error_Handler();

}

 

TxMessage.DLC = 8;

TxMessage.RTR = CAN_RTR_DATA;

TxMessage.IDE = CAN_ID_EXT;

//priority, PGN, address, id

set_can_id(0x04, 0xFFD1, 0x10, &CAN_id_xlor);

TxMessage.ExtId = CAN_id_xlor; //TODO: check if correct

//send data example

//HAL_CAN_AddTxMessage(&hcan, &TxMessage, const uint8_t aData, uint32_t (uint32_t *)CAN_TX_MAILBOX0);

/* USER CODE END CAN_Init 2 */

 

}

 

I send data every 40ms as follows:

CAN_send_status2();

 

Function definition:

void CAN_send_status2(void)

{

uint32_t mb = CAN_TX_MAILBOX0;

 

//init can id for this device - TODO: add other devices and define how to grab device

//priority, PGN, address, id

set_can_id(0x04, 0xFFD2, 0x10, &CAN_id_xlor);

 

TxMessage.ExtId = CAN_id_xlor;

TxMessage.RTR = CAN_RTR_DATA;

TxMessage.IDE = CAN_ID_EXT;

TxMessage.DLC = 8;

//TODO: add angle sensor faults? Overvoltage/under voltage warning?

if(pem_flash_mirror[ZERO_ANGLE_OCCURRED_FLASH_INDEX] == ZERO_OCCURRED_KEY)

tData[0] = 0x7F;

else

tData[0] = 0xFF;

tData[1] = 0xFF;

tData[2] = (position_variables.linearized_position >> 8) & 0xFF; //get high byte

tData[3] = position_variables.linearized_position & 0xFF; //get lower byte

tData[4] = 0xFF;

tData[5] = 0xFF;

tData[6] = 0xFF;

tData[7] = 0xFF;

 

HAL_CAN_AddTxMessage(&hcan, &TxMessage, tData, &mb);

 

}

Any clues?

I am not sure why data would not be send through the bus.

I have not worked on rx routines due to waiting on a transceiver.

Thank you!

0 REPLIES 0