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

CAN Filters issue

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



Joined: 01 Feb 2006
Posts: 64
Location: England

View user's profile Send private message Visit poster's website

CAN Filters issue
PostPosted: Wed May 30, 2007 3:48 pm     Reply with quote

Hi,

With setting the most restictive mask (0x07FF, all 11bits) for RX0MASK, I only recieve messages through RXFILTER0 (i.e. recieve only rxid1), and do not recieve rxid2?

If I set the mask to 0x00FF then I recieve messages, rxid1 & rxid2. But this means slackening off the filter and allowing many more though.

My two rxIDs are 0x0203 and 0x0503 (b01000000011 and b10100000011, bits 11,10,8 are different), all three bits for the different masks.

Code:

void can_filt( int16 rxid1,rxid2,rxid3,rxid4,rxid5,rxid6 )
{
   can_set_mode(CAN_OP_CONFIG); 

   can_set_id(RX0MASK, 0x07FF, 0);    //set mask 0 // MATCH MASK 100%
   can_set_id(RX0FILTER0, rxid1, 0);  //set filter 0 of mask 0
   can_set_id(RX0FILTER1, rxid2, 0);  //set filter 1 of mask 0

   can_set_id(RX1MASK, 0x07FF, 0);    //set mask 1 // MATCH MASK 100%
   can_set_id(RX1FILTER2, rxid3, 0);  //set filter 0 of mask 1
   can_set_id(RX1FILTER3, rxid4, 0);  //set filter 1 of mask 1
   can_set_id(RX1FILTER4, rxid5, 0);  //set filter 2 of mask 1
   can_set_id(RX1FILTER5, rxid6, 0);  //set filter 3 of mask 1

   can_set_mode(CAN_OP_NORMAL);
}


Compiler 3.249, PIC18F2680, CAN 2.0A (i.e. standard 11bit IDs only),

Can anyone explain why the filter mask is causing issues?

Am I missing something?

I've read
Quote:
For RBX0, two checks are made since it has two acceptance filters.
on http://www.elecdesign.com/Articles/Print.cfm?AD=1&AD=1&AD=1&ArticleID=10925, but I don't understand how this would work, and having re-read the PIC data sheet understand that should either filter and mask be accepted then the message is written to the buffer. I think this is just confusing my understanding!

Cheers Scott
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 30, 2007 4:29 pm     Reply with quote

Quote:
void can_filt( int16 rxid1,rxid2,rxid3,rxid4,rxid5,rxid6 )

There's a problem in the line of code above. You're making an
assumption about data type declarations in the parameter list.

Read the section on "parameter list" near the top of this C language guide.
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/1.3.html
ferrumvir



Joined: 01 Feb 2006
Posts: 64
Location: England

View user's profile Send private message Visit poster's website

PostPosted: Thu May 31, 2007 12:53 am     Reply with quote

Thanks PCM Prorammer,

It's always something simple... Embarassed Though I've not tried it, it makes perfect sence. Smile

Cheers Scott
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