cancel
Showing results for 
Search instead for 
Did you mean: 

I want to make an OBD car project as my major project, I read about CAN protocol and its filtering but I'm not able to use filters in stm32 directly so I google & found your repo https://github.com/ARoozitalab/ELM327-OBDII-STM32 but when I'm trying to

ATama.1
Associate II

I want to write fresh code so how can I write it

4 REPLIES 4

The Reference Manual shows the bit/wire position of the signal, the filtering allows you to Mask (AND) and Compare the bits that drop out.

Please don't put entire question in Title/Summary. You can edit posts to fix content and formatting.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AScha.3
Chief III

read...here a guy working with stm32 to get CAN data :

https://github.com/karlyamashita/CAN-X/wiki

If you feel a post has answered your question, please click "Accept as Solution".

Hey sir the above code is based on other hardware but I have only stm32f103

so I would like to use the ARoozitalab code cause it is based on the same stm32f103 controller can you please help me to modify this code from Keil to the new stm32 cube IDE, mainly I just wanna know the structuring in stm32cude ide to start my code

Javier1
Principal

I found this guy's post very useful when i first got started with canbus {german}

https://www.diller-technologies.de/stm32.html

This is what i do after i generated the code with cubeMX: (interrupt triggered canbus Rx)

CAN_HandleTypeDef *_hcan;
CAN_FilterTypeDef canfilter;
 
void CanSETUPnoFilter(CAN_HandleTypeDef *hcan_object_reference) {
	_hcan = hcan_object_reference;
	canfilter.FilterActivation = CAN_FILTER_ENABLE; //CAN_FILTER_ENABLE;//CAN_FILTER_DISABLE
	canfilter.FilterBank = 0;
	canfilter.FilterFIFOAssignment = CAN_FILTER_FIFO0; //CAN_FILTER_FIFO1
	canfilter.FilterIdHigh = 0;
	canfilter.FilterIdLow = 0;
	canfilter.FilterMaskIdHigh = 0;
	canfilter.FilterMaskIdLow = 0;
	canfilter.FilterMode = CAN_FILTERMODE_IDMASK; //CAN_FILTERMODE_IDMASK;//CAN_FILTERMODE_IDLIST
	canfilter.FilterScale = CAN_FILTERSCALE_32BIT; //CAN_FILTERSCALE_32BIT
	canfilter.SlaveStartFilterBank = 0;
 
	HAL_CAN_ConfigFilter(_hcan, &canfilter);
	HAL_CAN_ActivateNotification(_hcan, CAN_IT_RX_FIFO0_MSG_PENDING); //activate interrupt for received canbus
	HAL_CAN_Start(_hcan); //CRANK UP THE MOTORS!! BRRREM BRRREM starts can
 
}

As i handle the fifo0 received canbus frames inside an interruption , i need to redeclare HAL_CAN_RxFifo0MsgPendingCallback . (is declared as weak somewhere else)

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan){
	decodeIRQReceivedCanBus(hcan);
}

we dont need to firmware by ourselves, lets talk