CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

dsPIC33EP, can-pic24_dspic33.c driver mask and filter help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
WalkOver



Joined: 14 May 2021
Posts: 14

View user's profile Send private message

dsPIC33EP, can-pic24_dspic33.c driver mask and filter help
PostPosted: Fri May 14, 2021 3:02 am     Reply with quote

Hello Smile

I am still a young padawan in C language and I need help with this CCS CAN driver ( and CAN bus in general ).

I have a custom board and the CAN bus works like charm without filter.
I send data and receive data on interruption, no problem.

But now, I would like to implement filter. So I use define before can_init();
but I receive no data on the bus.

I just want to receive message with 0x300 ID for example.
So I config filter 0 to 0x300 and mask 0 to 0x00000000 but it seems it is not the right way to do that.
Code:

#define CAN_USE_FILTERS                TRUE
   
#define CAN_USER_FILT_0                0x00000300    // x being the filter to enable (0-15), and aa being the Id to filter for.
#define CAN_USER_FILT_0_TYPE           CAN_FILTER_TYPE_EID    // x being the filter to setup (0-15), and bb being the filter type:
                                                //    CAN_FILTER_TYPE_SID - filter Id is a SID Id, only the SID bit of filter are written the EID bits are set to 0.
                                                //    CAN_FILTER_TYPE_EID - filter Id is an EID Id, the SID and EID bits of filter are written.
#define CAN_USER_FILT_0_BUFFER         CAN_FILTER_BUFFER_0    // x being the filter to setup (0-15), and cc being the buffer to assign.
                                                // the filter to, see CAN_FILTER_BUFFER for options.
#define CAN_USER_FILT_0_MASK           CAN_FILTER_MASK_0    // x being the filter to setup (0-15), and dd being the mask to use with
                                                // the filter, see CAN_FILTER_MASK for options.
   
#define CAN_USER_MASK_0                0x00000000     // y being the mask to setup (0-2), and ee being the Mask for the filter Id.
#define CAN_USER_MASK_0_ID_TYPE        CAN_MASK_ID_TYPE_EID    // y being the mask to setup (0-2), and ff being the Mask Id type:
                                                //    CAN_MASK_ID_TYPE_SID - mask Id is a SID Id, only the SID bits of Mask are written the EID bits are set to 0.
                                                //    CAN_MASK_ID_TYPE_EID - mask Id is an EID Id, the SID and EID bits of Mask are written.
#define CAN_USER_MASK_0_FILTER_TYPE    CAN_FILTER_MASK_TYPE_EITHER    // y being the mask to setup (0-2), and gg being the filter mask type:
                                                //    CAN_FILTER_MASK_TYPE_EITHER - match either SID or EID messages, ignores EXIDE bit of filter.
                                                //    CAN_FILTER_MASK_TYPE_SID_OR_EID - only match SID or EID messages, EXIDE bit of filter determines type of messages received.
                                               
#include <can-pic24_dsPIC33.c>


It is possible to have some help or guidance ?
Thank you very much Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Fri May 14, 2021 10:25 am     Reply with quote

See newguy's table at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=51209
Ttelmah



Joined: 11 Mar 2010
Posts: 17330

View user's profile Send private message

PostPosted: Fri May 14, 2021 10:59 am     Reply with quote

The key document that needs a lot of reading is 70070D.pdf from
Microchip. This has the filter description given above in paragraph
23.7.2, but also an enormous amount more about how the filters work
DBEN also changes what filters can be used, and how multiple filters
work together. It really is essential reading, but rather big... Sad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group