How to read CAN BUS with STM32F091RC + MCP2551 transreceiver?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-12 10:58 AM
Hi I am trying to read car CAN BUS with STM32F091RC + MCP2551 transreceiver. All I am getting is empty header and data. I guess my setup is incorrect, anyone can advice how to setup?
This is my setup:
CAN_TxHeaderTypeDef TxHeader;
CAN_RxHeaderTypeDef RxHeader;
uint8_t TxData[8];
uint8_t RxData[8];
uint32_t TxMailbox;
HAL_CAN_Start(&hcan);
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* Get RX message */
if (HAL_CAN_GetRxMessage(&hcan, CAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
{
/* Reception Error */
Error_Handler();
}
if (
RxData[0] != 0 ||
RxData[1] != 0 ||
RxData[2] != 0 ||
RxData[3] != 0 ||
RxData[4] != 0 ||
RxData[5] != 0 ||
RxData[6] != 0 ||
RxData[7] != 0 ||
RxHeader.DLC != 0 ||
RxHeader.ExtId != 0 ||
RxHeader.FilterMatchIndex != 0 ||
RxHeader.IDE != 0 ||
RxHeader.RTR != 0 ||
RxHeader.StdId != 0 ||
RxHeader.Timestamp != 0
)
{
BSP_LED_On(LED2);
}
}
Solved! Go to Solution.
- Labels:
-
CAN
-
STM32F0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-14 6:29 AM
>>Any help?
Unfortunately multiple degrees of separation in terms of chips, tools, and libraries.
Suspect you'll need to search/grep the library source to understand specifically what is not liked in your parameters, presumably clocks, quanta, or other combination of thing that the library determines to be internally inconsistent.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-13 12:21 PM
Any help? I am reading can and getting all zeros when connected to car CAN bus. Why could I get zeroes?
I have connected transreceviver to PB8 and PB9.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-14 3:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-14 4:07 AM
#define HAL_CAN_ERROR_PARAM (0x00200000U) /*!< Parameter error
As I understand I am getting this error. What does this error mean and how to fix it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-14 6:29 AM
>>Any help?
Unfortunately multiple degrees of separation in terms of chips, tools, and libraries.
Suspect you'll need to search/grep the library source to understand specifically what is not liked in your parameters, presumably clocks, quanta, or other combination of thing that the library determines to be internally inconsistent.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-14 2:36 PM
It started working!
I have calculated correct quantas by this video:
https://www.youtube.com/watch?v=rpE5UvQDcy4&list=PLERTijJOmYrApVZqiI6gtA8hr1_6QS-cs&index=14
Does power source matter? Can each CAN node be on different power source? Also different power source for transceiver?
Power source does not matter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-26 8:11 AM
This file is not available on GitHub. Do you still have the files available?
