2024-03-25 03:39 AM - last edited on 2024-03-25 05:51 AM by SofLit
Hello, i am using f446re nucleo board and have been facing a problem for a while now. I need to establish a loopback CAN transmission and the debug mode allows me to find a bug in the CAN Start function: HAL_ERROR 0x1 returned everytime i attempt.
here is the while loop i am talking about:
while((hcan->Instance->MSR & CAN_MSR_INAK) != 0)
{
if((HAL_GetTick() -tickstart) > CAN_TIMEOUT_VALUE)
{
hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;
hcan->State = HAL_CAN_STATE_ERROR;
return HAL_ERROR;
}
}
Solved! Go to Solution.
2024-03-25 05:49 AM
Configure CAN_Rx pin (PA11) in pullup mode:
2024-03-25 03:41 AM
Hello,
Could you please share your code or your ioc file if you're using CubeMx?
Share the GPIO pin configurations.
2024-03-25 03:46 AM
Thank you for your quick answer!
Here is the GPIO config from the .ioc
2024-03-25 03:54 AM
I need your ioc file. please attach it.
2024-03-25 05:33 AM
2024-03-25 05:49 AM
Configure CAN_Rx pin (PA11) in pullup mode:
2024-03-25 07:09 AM
Thank you for your help. I don,t know how come this worked but it did.
Another problem i am facing is i am trying to display the frame using the picoscope. I Wrote a function that initialise the Header Struct, and send the data, but nothing on the screen, can you help me one more time? he re is the function i wrote:
void CAN_send(void)
{
char msg[50];
CAN_TxHeaderTypeDef TxHeader;
uint8_t TxData[4] = {'T','E','S','T'};
TxHeader.DLC = 4; // 4 data byte
TxHeader.ExtId = 0; // Not used so far
TxHeader.IDE = CAN_ID_STD; // Standard ID
TxHeader.RTR = CAN_RTR_DATA; // Data and not remote frame
TxHeader.StdId = 0x103; // Data ID
TxHeader.TransmitGlobalTime = DISABLE;
if(HAL_CAN_AddTxMessage(&hcan1, &TxHeader, TxData, &TxMailbox)!=HAL_OK)
{
Error_Handler();
}
while( HAL_CAN_IsTxMessagePending(&hcan1, TxMailbox));
sprintf(msg, "Message transmitted\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
}
2024-03-25 07:18 AM - edited 2024-03-25 07:19 AM
Hello,
Since the original question was answered, I invite you to open a new thread and tag me there, I will gladly help you on this new question ;).