snoop911
Joined: 24 Aug 2007 Posts: 4
|
CAN Bus Example - Doesn't work For Mode 2 |
Posted: Mon Nov 10, 2008 11:40 pm |
|
|
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 ? |
|