CAN IDs and filtering

Started by scuthbertf September 19, 2003
I have experimented with the following code snippets trying to figure
out how the mask registers and acceptance registers work. If anyone
can see how to do this correctly I would really love to know!!!
;
; USING: AXIOM CME12D60A development board
; D60A chip experimental CAN program using LOOPBACK mode
; CAN RX and TX are set up as interrupts
;
; REFERENCES: AN2010, AN1828, AN2283 Motorola application notes
;
;---------------------------------
; code snippet of initialization after SOFT_RES
;
movw #$20,CIDAC ; eight 8-bit filters

movb #$07,CIDMR0 ; 8 bit mask CIDMR0
movb #$07,CIDMR1 ; & CIDMR1
movb #$00,CIDAR0 ; 8 bit CIDAR0
movb #$01,CIDAR1 ; & CIDAR1 accept filter

movb #$07,CIDMR2 ; 8 bit mask CIDMR2
movb #$07,CIDMR3 ; & CIDMR3
movb #$02,CIDAR2 ; 8 bit CIDAR2
movb #$03,CIDAR3 ; & CIDAR3 accept filter

movb #$07,CIDMR4 ; 8 bit mask CIDMR4
movb #$07,CIDMR5 ; & CIDMR5
movb #$04,CIDAR4 ; 8 bit CIDAR4
movb #$05,CIDAR5 ; & CIDAR5 accept filter

movb #$07,CIDMR6 ; 8 bit mask CIDMR6
movb #$07,CIDMR7 ; & CIDMR7
movb #$06,CIDAR6 ; 8 bit CIDAR6
movb #$07,CIDAR7 ; & accept filter

;---------------------------------
; 2 messages are sent, each with the 4 ID bytes as shown below
;
movb #$13,TXMSG+0 ; IDR0 ; this value is changed
according to msg sent
movb #$00,TXMSG+1 ; IDR1 ; these values are always set
to this
movb #$00,TXMSG+2 ; IDR2 ; as I am using eight 8-bit
filters
movb #$00,TXMSG+3 ; IDR3 ; in the program

;=====================================================================
The objective is:
1. to have messages with IDR0 with a value of $00, $01, $02, or $03
sent by master CAN node and ALL 4 slave nodes receive the message via
filtering
at the each slave node
2. each slave node will have it's own set of IDs, slave node 1 would
have $10 - $13
and any message with these IDs would be filtered out by all node
except node 1,
which would accept messages with these IDs. Slave node 2 would have
a set of IDs
in the range of $20 - $23, node 3 would have the set of IDs in the
range of $30 -$33
and the last node (4) would use $40 -$43. The master node (0)
accepts $00 - $03
from any node.
3. it is not mandatory that I use eight 8-bit filter configuration, I
just started
using the 8x8 configuration because it looked like the easiest
configuration to use.
;=====================================================================
I tried setting masks CIDMR0 - 7 at $07, with CIDAR0 - 7 at $00 up to
$07 and could
get the filtering to allow only msgs with IDs $00 - $07 as expected.
Node 0 could use
this! Then I changed the CIDAR0 -7 to $10 - $17 and tried msgs with
IDR0 set to $10 to
$17 and no messages got through! Ditto for other versions where the
CIDAR0 - 7 were set
to $20-$27 or $30-$37 and appropriate msg IDs tried! I thought the
unmasked bits were
supposed to match the CIDAR bits, 0 to 0, and 1 to 1! What is going
on? I'm
baffled!