cancel
Showing results for 
Search instead for 
Did you mean: 

need help setting CAN Rx acceptance mask and filter on a (old) STR73x processor, copied this from the STM32 MCUs Products forum

mafredette
Associate

I read the CAN section of the RM0001 Reference manuaI STR73x ARMTDMI microcontroller family a few times, but still don't understand how to set acceptance masking and filtering.

I want to only accept CAN extended messages with 29 bit headers that match the following...

x xxx 0000 xxxxxx xx 001001 00 xxx xx

Am I correct that the mask is set in CAN_IF2_M1R and M2R regs? And that a '1' tells the filter to test that bit, a '0' to ignore that bit?

And then, the filter is set in the CAN_IF2_A1R and A2R regs? So the bit values in the unmasked positions of the received header are compared to the bits in corresponding positions in the AR regs? And only if they match, will the message will trigger an interrupt?

So, for my example, I would set...

MR1 = 0 00 111111 11 000 00

MR2 = 0 000 1111 00000

AR1 = x xx 001001 00 xxx xx

AR2 = x xxx 0000 xxxxx

Am I on the right track?

 

There is a function in the st73x lib and in 73x_can.c, CANSetRxMsgObj() , but it sets both MR and AR, and does not allow setting them independently. Should I just set the regs manually?

1 REPLY 1

https://www.st.com/resource/en/reference_manual/cd00164537-str73x-armtdmi-microcontroller-family-stmicroelectronics.pdf

MR2.15 needs to be ONE for 29-bit extended messages

AR2.14 1=29-bit

AR2.15 1=MsgVal

MR1 = 0x1FE0

AR1 = 0x0480 // xxx0 0100 100x xxxx

MR2 = 0x81E0 // [100]0 0001 1110 0000

AR2 = 0xC000 // [110]x xxx0 000x xxxx

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