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 CCS Technical Support

CAN Bus Example - Doesn't work For Mode 2

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



Joined: 24 Aug 2007
Posts: 4

View user's profile Send private message

CAN Bus Example - Doesn't work For Mode 2
PostPosted: Mon Nov 10, 2008 11:40 pm     Reply with quote

I got the CCS CAN development board, and downloaded the CCS to compile some of the examples...

I'm using Ex.20 from the exercise book, which uses Node B to send data, with an RTR, message id == 0x500. It then waits for a response from Node A and outputs to the Serial.

Node A, in turn, is programmed to mode 1 with a 0xFF00 filter, and a 0x500 mask:

Code:

void main()
{
   int data[8] = {15, 14, 13, 12, 11, 10, 9, 8};   
   int receive[8];

   can_init();
   can_set_functional_mode(1);   // Mode 1
   can_enable_b_transfer(B1);
   can_disable_filter(0xffff);
   can_enable_filter(0x01);
   can_set_id(RX0MASK, 0xff00, TRUE);
   can_set_id(RXFILTER0, 0x500, TRUE);
   can_set_id(B1ID, 0x600, TRUE);
   can_associate_filter_to_mask(ACCEPTANCE_MASK_0, F0BP);
   can_associate_filter_to_buffer(AB1, F0BP);   // Not Needed for Mode 2?
   can_load_rtr(B1, data, 8);
   can_enable_rtr(B1);
   
   while(TRUE)
   {
       output_high(YELLOW_LED);
       delay_ms(1000);
       output_low(YELLOW_LED);
       delay_ms(1000);
   }
}


This works fine. However, if I change just Node A to mode 2, it doesn't work. The auto response to the RTR never occurs (as evident that Node B never outputs anything on the serial).

The only 2 lines I changed are:
Code:

   can_set_functional_mode(1);   // Mode 1

to
Code:

   can_set_functional_mode(1);   // Mode 2


and
Code:

   can_associate_filter_to_buffer(AB1, F0BP);

to
Code:

// can_associate_filter_to_buffer(AB1, F0BP);


The 2nd change was because (as I understand it) in Mode 2 Fifo mode, a filter should not get assigned to an individual buffer since it's a system Fifo mechanism.

Why is this seemingly innocuous change from mode 1 to mode 2 not working ?
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