760 likes | 998 Views
Controller Area Network (CAN). Lecture 5.1. Reference. S12MSCANV2.pdf. MSCAN Block Guide V02.14. PIM_9C32 Block Diagram. CAN module. PCA82C250 / 251 CAN Transceiver. Bit time =2500ns. 0.4 Mbps. 3m. =2(15ns + 150ns) = 330ns. 4MHz. 2. 250ns. 2500/250 = 10. 330/250 = 2. 2. 10.
E N D
Controller Area Network(CAN) Lecture 5.1
Reference S12MSCANV2.pdf MSCAN Block Guide V02.14
PIM_9C32 Block Diagram CAN module
PCA82C250 / 251 CAN Transceiver
Bit time =2500ns 0.4 Mbps 3m =2(15ns + 150ns) = 330ns
4MHz 2 250ns 2500/250 = 10 330/250 = 2 2 10 7 so PROP_SEG = 3, PHASE_SEG1 = 3 and PHASE_SEG2 = 3 RJW = 3
3 20x10 = 0.015 3 2(127) = 0.0118 2 10 3 3 3 3 1.18%
$141 BSET CANCTL1,#$80 ;turn on CAN
$141 ;place CAN in init mode CAN_INI BSET CANCTL0,#$01 BRCLR CANCTL1,#$01,CAN_INI
$141 ;Bus clock, listen off LDAA #$C0 STAA CANCLT1
$140 ;CSWAI,WUPE,TIME,SLPRQ off BCLR CANCTL0,#$2E
$140 ;CSWAI,WUPE,TIME,SLPRQ off BCLR CANCTL0,#$2E
1 3 + 3 = 6 3
$142 1 0
$142 1 0 0 0 0 0 0 1 MOVB #$81,CANBTR0 Prescale = 2
$143 0 0 1 0 TSEG2 = 3 0 1 0 3 Tq clock cycles
0 0 1 0 0 1 0 1 $143 TSEG1 = 6 0 1 0 1 6 Tq clock cycles MOVB #$25,CANBTR1
ID = 127 ID = 1 IDR0 = $00 IDR1 = $18 IDR2 = $00 IDR3 = $02 IDR0 = $00 IDR1 = $18 IDR2 = $00 IDR3 = $FE
$150 $151 $152 $153
$158 $159 $15A $15B
$154 $155 $156 $157
$15C $15D $15E $15F
$14B MOVB #$00,CANIDAC
ID = 127 $FFFF0001 $FFFF0001 $001800FE
ID = 1 $FFFF0001 $FFFF0001 $00180002
;Acceptance & Mask registers MOVW #$0018,CAN0IDA0 ; ID = $0018 MOVW #$00FE,CAN0IDA2 ; ID = $00FE MOVW #$FFFF,CAN0IDM0 ; filter = $FFFF MOVW #$0001,CAN0IDM2 ; filter = $0001 MOVW #$0018,CAN0IDA4 ; ID = $0018 MOVW #$0002,CAN0IDA6 ; ID = $0002 MOVW #$FFFF,CAN0IDM4 ; filter = $FFFF MOVW #$0001,CAN0IDM6 ; filter = $0001
EXIT CAN INIT MODE $140 BCLR CANCTL0,#$01
$140 ;wait for sync SYNC BRCLR CANCTL0,#$10,SYNC
LDAB DLR ANDB #$0F