-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCAN.C
executable file
·2156 lines (1805 loc) · 98.5 KB
/
CAN.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//****************************************************************************
// @Module MultiCAN Module (CAN)
// @Filename CAN.C
// @Project test3.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC2267M-104F80
//
// @Compiler Keil
//
// @Codegenerator 2.0
//
// @Description This file contains functions that use the CAN module.
//
//----------------------------------------------------------------------------
// @Date 2018/11/1 16:59:46
//
//****************************************************************************
// USER CODE BEGIN (CAN_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (CAN_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (CAN_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (CAN_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (CAN_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (CAN_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (CAN_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (CAN_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (CAN_General,9)
// USER CODE END
//****************************************************************************
// @Function void CAN_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the CAN function
// library. It is assumed that the SFRs used by this library
// are in reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2018/11/1
//
//****************************************************************************
// USER CODE BEGIN (Init,1)
// USER CODE END
void CAN_vInit(void)
{
// USER CODE BEGIN (Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of Kernel State Configuration Register:
/// -----------------------------------------------------------------------
/// - Enable the CAN module(MODEN)
/// - Enable Bit Protection for MODEN
MCAN_KSCCFG = 0x0003; // load Kernel State Configuration Register
_nop_(); // one cycle delay
_nop_(); // one cycle delay
/// -----------------------------------------------------------------------
/// Configuration of the Module Clock:
/// -----------------------------------------------------------------------
/// - the CAN module clock = 40.00 MHz
/// - Normal divider mode selected
CAN_FDRL = 0x43FE; // load Fractional Divider Register
/// -----------------------------------------------------------------------
/// Panel Control
/// -----------------------------------------------------------------------
/// - wait until Panel has finished the initialisation
while(CAN_PANCTRL & CAN_PANCTR_BUSY){ // wait until Panel has finished
// the initialisation
}
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 0:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 0:
/// - set INIT and CCE
CAN_NCR0 = 0x0041; // load NODE 0 control register[15-0]
/// - load NODE 0 interrupt pointer register
CAN_NIPR0 = 0x0000; // load NIPR0_LECINP, ALINP, CFCINP and TRINP
/// Configuration of the used CAN Port Pins:
/// - Loop-back mode is disabled
/// - P2.0 is used for CAN0 Receive input(RXDC0C)
/// - P2.1 is used for CAN0 Transmit output(TXDC0C)
P2_IOCR01 = 0x0090; //set direction register
CAN_NPCR0 = 0x0002; // load node0 port control register
/// Configuration of the Node 0 Baud Rate:
/// - required baud rate = 250.000 kbaud
/// - real baud rate = 250.000 kbaud
/// - sample point = 60.00 %
/// - there are 5 time quanta before sample point
/// - there are 4 time quanta after sample point
/// - the (re)synchronization jump width is 2 time quanta
CAN_NBTR0L = 0x344F; // load NBTR0_DIV8, TSEG2, TSEG1, SJW and BRP
/// Configuration of the Node 0 Error Counter:
/// - the error warning threshold value (warning level) is 96
CAN_NECNT0H = 0x0060; // load NECNT0_EWRNLVL register
CAN_NECNT0L = 0x0000;
/// Configuration of the Frame Counter:
/// - Frame Counter Mode: the counter is incremented upon the reception
/// and transmission of frames
/// - frame counter: 0x0000
CAN_NFCR0H = 0x0000; // load NFCR0_CFCOV, CFCIE, CFMOD, CFSEL
CAN_NFCR0L = 0x0000; // load NFCR0_CFC
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 1:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 1:
/// - set INIT and CCE
CAN_NCR1 = 0x0041; // load NODE 1 control register[15-0]
/// - load NODE 1 interrupt pointer register
CAN_NIPR1 = 0x0000; // load NIPR1_LECINP, ALINP, CFCINP and TRINP
/// Configuration of the used CAN Port Pins:
/// - Loop-back mode is disabled
/// - P0.4 is used for CAN1 Receive input(RXDC1B)
/// - P0.6 is used for CAN1 Transmit Output(TXDC1A)
P0_IOCR06 = 0x00A0; //set direction register
CAN_NPCR1 = 0x0001; // load node1 port control register
/// Configuration of the Node 1 Baud Rate:
/// - required baud rate = 250.000 kbaud
/// - real baud rate = 250.000 kbaud
/// - sample point = 60.00 %
/// - there are 5 time quanta before sample point
/// - there are 4 time quanta after sample point
/// - the (re)synchronization jump width is 2 time quanta
CAN_NBTR1L = 0x344F; // load NBTR1_DIV8, TSEG2, TSEG1, SJW and BRP
/// Configuration of the Node 1 Error Counter:
/// - the error warning threshold value (warning level) is 96
CAN_NECNT1H = 0x0060; // load NECNT1_EWRNLVL register
CAN_NECNT1L = 0x0000;
/// Configuration of the Frame Counter:
/// - Frame Counter Mode: the counter is incremented upon the reception
/// and transmission of frames
/// - frame counter: 0x0000
CAN_NFCR1H = 0x0000; // load NFCR1_CFCOV, CFCIE, CFMOD, CFSEL
CAN_NFCR1L = 0x0000; // load NFCR1_CFC
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 2:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 2:
/// - set INIT and CCE
CAN_NCR2 = 0x0041; // load NODE 2 control register[15-0]
/// - load NODE 2 interrupt pointer register
CAN_NIPR2 = 0x0000; // load NIPR2_LECINP, ALINP, CFCINP and TRINP
/// Configuration of the used CAN Port Pins:
/// - Loop-back mode is disabled
/// - P4.3 is used for CAN2 Receive inputA(RXDC2A)
/// - P4.2 is used for CAN2 Transmit output(TXDC2B)
P4_IOCR02 = 0x00A0; //set direction register
CAN_NPCR2 = 0x0000; // load node2 port control register
/// Configuration of the Node 2 Baud Rate:
/// - required baud rate = 250.000 kbaud
/// - real baud rate = 250.000 kbaud
/// - sample point = 60.00 %
/// - there are 5 time quanta before sample point
/// - there are 4 time quanta after sample point
/// - the (re)synchronization jump width is 2 time quanta
CAN_NBTR2L = 0x344F; // load NBTR2_DIV8, TSEG2, TSEG1, SJW and BRP
/// Configuration of the Node 2 Error Counter:
/// - the error warning threshold value (warning level) is 96
CAN_NECNT2H = 0x0060; // load NECNT2_EWRNLVL register
CAN_NECNT2L = 0x0000;
/// Configuration of the Frame Counter:
/// - Frame Counter Mode: the counter is incremented upon the reception
/// and transmission of frames
/// - frame counter: 0x0000
CAN_NFCR2H = 0x0000; // load NFCR2_CFCOV, CFCIE, CFMOD, CFSEL
CAN_NFCR2L = 0x0000; // load NFCR2_CFC
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 3:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 3:
/// - set INIT and CCE
CAN_NCR3 = 0x0041; // load NODE 3 control register[15-0]
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 4:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 4:
/// - set INIT and CCE
CAN_NCR4 = 0x0041; // load NODE 4 control register[15-0]
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 5:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 5:
/// - set INIT and CCE
CAN_NCR5 = 0x0041; // load NODE 5 control register[15-0]
/// -----------------------------------------------------------------------
/// Configuration of the CAN Message Object List Structure:
/// -----------------------------------------------------------------------
/// Allocate MOs for list 1:
SetListCommand(0x0105,0x0002); // MO5 for list 1 (Node 0)
SetListCommand(0x0102,0x0002); // MO2 for list 1 (Node 0)
SetListCommand(0x0101,0x0002); // MO1 for list 1 (Node 0)
/// Allocate MOs for list 2:
SetListCommand(0x0204,0x0002); // MO4 for list 2 (Node 1)
SetListCommand(0x0203,0x0002); // MO3 for list 2 (Node 1)
/// Allocate MOs for list 3:
SetListCommand(0x0300,0x0002); // MO0 for list 3 (Node 2)
/// -----------------------------------------------------------------------
/// Configuration of the CAN Message Objects 0 - 254:
/// -----------------------------------------------------------------------
/// -----------------------------------------------------------------------
/// Configuration of Message Object 0:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 0 :
/// - message object 0 is valid
/// - message object is used as transmit object
/// - this message object is assigned to list 3 (node 2)
CAN_MOCTR0H = 0x0EA8; // load MO0 control register high
CAN_MOCTR0L = 0x0000; // load MO0 control register low
/// Configuration of Message Object 0 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - standard 11-bit identifier
/// - identifier 11-bit: 0x203
CAN_MOAR0H = 0x480C; // load MO0 arbitration register high
CAN_MOAR0L = 0x0000; // load MO0 arbitration register low
/// Configuration of Message Object 0 Data:
CAN_MODATA0HH = 0x0000; // load MO0 Data Bytes(DB7 & DB6)
CAN_MODATA0HL = 0x0000; // load MO0 Data Bytes(DB5 & DB4)
CAN_MODATA0LH = 0x0000; // load MO0 Data Bytes(DB3 & DB2)
CAN_MODATA0LL = 0x0000; // load MO0 Data Bytes(DB1 & DB0)
/// Configuration of Message Object 0 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 11-bit: 0x7FF
CAN_MOAMR0H = 0x3FFF; // load MO0 acceptance mask register high
CAN_MOAMR0L = 0xFFFF; // load MO0 acceptance mask register low
/// Configuration of Message Object 0 interrupt pointer:
/// - use message pending register 0 bit position 0
CAN_MOIPR0H = 0x0000; // load MO0 interrupt pointer register high
CAN_MOIPR0L = 0x0000; // load MO0 interrupt pointer register low
/// Configuration of Message Object 0 FIFO/Gateway pointer:
CAN_MOFGPR0H = 0x0000; // load MO0 FIFO/gateway pointer register
// high
CAN_MOFGPR0L = 0x0000; // load MO0 FIFO/gateway pointer register low
/// Configuration of Message Object 0 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
CAN_MOFCR0H = 0x0800; // load MO0 function control register high
CAN_MOFCR0L = 0x0000; // load MO0 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 1:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 1 :
/// - message object 1 is valid
/// - message object is used as transmit object
/// - this message object is assigned to list 1 (node 0)
CAN_MOCTR1H = 0x0EA8; // load MO1 control register high
CAN_MOCTR1L = 0x0000; // load MO1 control register low
/// Configuration of Message Object 1 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x08C1EF21
CAN_MOAR1H = 0x68C1; // load MO1 arbitration register high
CAN_MOAR1L = 0xEF21; // load MO1 arbitration register low
/// Configuration of Message Object 1 Data:
CAN_MODATA1HH = 0x0000; // load MO1 Data Bytes(DB7 & DB6)
CAN_MODATA1HL = 0x0000; // load MO1 Data Bytes(DB5 & DB4)
CAN_MODATA1LH = 0x0000; // load MO1 Data Bytes(DB3 & DB2)
CAN_MODATA1LL = 0x0000; // load MO1 Data Bytes(DB1 & DB0)
/// Configuration of Message Object 1 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 29-bit: 0x1FFFFFFF
CAN_MOAMR1H = 0x3FFF; // load MO1 acceptance mask register high
CAN_MOAMR1L = 0xFFFF; // load MO1 acceptance mask register low
/// Configuration of Message Object 1 interrupt pointer:
/// - use message pending register 0 bit position 1
CAN_MOIPR1H = 0x0000; // load MO1 interrupt pointer register high
CAN_MOIPR1L = 0x0100; // load MO1 interrupt pointer register low
/// Configuration of Message Object 1 FIFO/Gateway pointer:
CAN_MOFGPR1H = 0x0000; // load MO1 FIFO/gateway pointer register
// high
CAN_MOFGPR1L = 0x0000; // load MO1 FIFO/gateway pointer register low
/// Configuration of Message Object 1 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
CAN_MOFCR1H = 0x0800; // load MO1 function control register high
CAN_MOFCR1L = 0x0000; // load MO1 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 2:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 2 :
/// - message object 2 is valid
/// - message object is used as receive object
/// - this message object is assigned to list 1 (node 0)
CAN_MOCTR2H = 0x00A0; // load MO2 control register high
CAN_MOCTR2L = 0x0000; // load MO2 control register low
/// Configuration of Message Object 2 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x0CFFC6EF
CAN_MOAR2H = 0x6CFF; // load MO2 arbitration register high
CAN_MOAR2L = 0xC6EF; // load MO2 arbitration register low
/// Configuration of Message Object 2 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 29-bit: 0x1FFFFFFF
CAN_MOAMR2H = 0x3FFF; // load MO2 acceptance mask register high
CAN_MOAMR2L = 0xFFFF; // load MO2 acceptance mask register low
/// Configuration of Message Object 2 interrupt pointer:
/// - use message pending register 0 bit position 2
/// - receive interrupt node pointer: MultiCAN SRN 0
CAN_MOIPR2H = 0x0000; // load MO2 interrupt pointer register high
CAN_MOIPR2L = 0x0200; // load MO2 interrupt pointer register low
/// Configuration of Message Object 2 FIFO/Gateway pointer:
CAN_MOFGPR2H = 0x0000; // load MO2 FIFO/gateway pointer register
// high
CAN_MOFGPR2L = 0x0000; // load MO2 FIFO/gateway pointer register low
/// Configuration of Message Object 2 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
/// - enable receive interrupt; bit RXPND is set after successful
/// reception of a frame
CAN_MOFCR2H = 0x0801; // load MO2 function control register high
CAN_MOFCR2L = 0x0000; // load MO2 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 3:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 3 :
/// - message object 3 is valid
/// - message object is used as receive object
/// - this message object is assigned to list 2 (node 1)
CAN_MOCTR3H = 0x00A0; // load MO3 control register high
CAN_MOCTR3L = 0x0000; // load MO3 control register low
/// Configuration of Message Object 3 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x186040F3
CAN_MOAR3H = 0x7860; // load MO3 arbitration register high
CAN_MOAR3L = 0x40F3; // load MO3 arbitration register low
/// Configuration of Message Object 3 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 29-bit: 0x1FFFFFFF
CAN_MOAMR3H = 0x3FFF; // load MO3 acceptance mask register high
CAN_MOAMR3L = 0xFFFF; // load MO3 acceptance mask register low
/// Configuration of Message Object 3 interrupt pointer:
/// - use message pending register 0 bit position 3
/// - receive interrupt node pointer: MultiCAN SRN 0
CAN_MOIPR3H = 0x0000; // load MO3 interrupt pointer register high
CAN_MOIPR3L = 0x0300; // load MO3 interrupt pointer register low
/// Configuration of Message Object 3 FIFO/Gateway pointer:
CAN_MOFGPR3H = 0x0000; // load MO3 FIFO/gateway pointer register
// high
CAN_MOFGPR3L = 0x0000; // load MO3 FIFO/gateway pointer register low
/// Configuration of Message Object 3 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
/// - enable receive interrupt; bit RXPND is set after successful
/// reception of a frame
CAN_MOFCR3H = 0x0801; // load MO3 function control register high
CAN_MOFCR3L = 0x0000; // load MO3 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 4:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 4 :
/// - message object 4 is valid
/// - message object is used as receive object
/// - this message object is assigned to list 2 (node 1)
CAN_MOCTR4H = 0x00A0; // load MO4 control register high
CAN_MOCTR4L = 0x0000; // load MO4 control register low
/// Configuration of Message Object 4 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x186240F3
CAN_MOAR4H = 0x7862; // load MO4 arbitration register high
CAN_MOAR4L = 0x40F3; // load MO4 arbitration register low
/// Configuration of Message Object 4 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 29-bit: 0x1FFFFFFF
CAN_MOAMR4H = 0x3FFF; // load MO4 acceptance mask register high
CAN_MOAMR4L = 0xFFFF; // load MO4 acceptance mask register low
/// Configuration of Message Object 4 interrupt pointer:
/// - use message pending register 0 bit position 4
/// - receive interrupt node pointer: MultiCAN SRN 0
CAN_MOIPR4H = 0x0000; // load MO4 interrupt pointer register high
CAN_MOIPR4L = 0x0400; // load MO4 interrupt pointer register low
/// Configuration of Message Object 4 FIFO/Gateway pointer:
CAN_MOFGPR4H = 0x0000; // load MO4 FIFO/gateway pointer register
// high
CAN_MOFGPR4L = 0x0000; // load MO4 FIFO/gateway pointer register low
/// Configuration of Message Object 4 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
/// - enable receive interrupt; bit RXPND is set after successful
/// reception of a frame
CAN_MOFCR4H = 0x0801; // load MO4 function control register high
CAN_MOFCR4L = 0x0000; // load MO4 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 5:
/// -----------------------------------------------------------------------
/// General Configuration of the Message Object 5 :
/// - message object 5 is valid
/// - message object is used as receive object
/// - this message object is assigned to list 1 (node 0)
CAN_MOCTR5H = 0x00A0; // load MO5 control register high
CAN_MOCTR5L = 0x0000; // load MO5 control register low
/// Configuration of Message Object 5 Arbitration:
/// - priority class 1; transmit acceptance filtering is based on the list
/// order
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x0CFFC7EF
CAN_MOAR5H = 0x6CFF; // load MO5 arbitration register high
CAN_MOAR5L = 0xC7EF; // load MO5 arbitration register low
/// Configuration of Message Object 5 acceptance mask:
/// - only accept receive frames with matching IDE bit
/// - acceptance mask 29-bit: 0x1FFFFFFF
CAN_MOAMR5H = 0x3FFF; // load MO5 acceptance mask register high
CAN_MOAMR5L = 0xFFFF; // load MO5 acceptance mask register low
/// Configuration of Message Object 5 interrupt pointer:
/// - use message pending register 0 bit position 5
/// - receive interrupt node pointer: MultiCAN SRN 0
CAN_MOIPR5H = 0x0000; // load MO5 interrupt pointer register high
CAN_MOIPR5L = 0x0500; // load MO5 interrupt pointer register low
/// Configuration of Message Object 5 FIFO/Gateway pointer:
CAN_MOFGPR5H = 0x0000; // load MO5 FIFO/gateway pointer register
// high
CAN_MOFGPR5L = 0x0000; // load MO5 FIFO/gateway pointer register low
/// Configuration of Message Object 5 Function control:
/// - this object is a STANDARD MESSAGE OBJECT
/// - 8 valid data bytes
/// - enable receive interrupt; bit RXPND is set after successful
/// reception of a frame
CAN_MOFCR5H = 0x0801; // load MO5 function control register high
CAN_MOFCR5L = 0x0000; // load MO5 function control register low
/// -----------------------------------------------------------------------
/// Configuration of Message Object 6:
/// -----------------------------------------------------------------------
/// - message object 6 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 7:
/// -----------------------------------------------------------------------
/// - message object 7 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 8:
/// -----------------------------------------------------------------------
/// - message object 8 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 9:
/// -----------------------------------------------------------------------
/// - message object 9 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 10:
/// -----------------------------------------------------------------------
/// - message object 10 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 11:
/// -----------------------------------------------------------------------
/// - message object 11 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 12:
/// -----------------------------------------------------------------------
/// - message object 12 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 13:
/// -----------------------------------------------------------------------
/// - message object 13 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 14:
/// -----------------------------------------------------------------------
/// - message object 14 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 15:
/// -----------------------------------------------------------------------
/// - message object 15 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 16:
/// -----------------------------------------------------------------------
/// - message object 16 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 17:
/// -----------------------------------------------------------------------
/// - message object 17 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 18:
/// -----------------------------------------------------------------------
/// - message object 18 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 19:
/// -----------------------------------------------------------------------
/// - message object 19 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 20:
/// -----------------------------------------------------------------------
/// - message object 20 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 21:
/// -----------------------------------------------------------------------
/// - message object 21 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 22:
/// -----------------------------------------------------------------------
/// - message object 22 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 23:
/// -----------------------------------------------------------------------
/// - message object 23 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 24:
/// -----------------------------------------------------------------------
/// - message object 24 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 25:
/// -----------------------------------------------------------------------
/// - message object 25 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 26:
/// -----------------------------------------------------------------------
/// - message object 26 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 27:
/// -----------------------------------------------------------------------
/// - message object 27 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 28:
/// -----------------------------------------------------------------------
/// - message object 28 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 29:
/// -----------------------------------------------------------------------
/// - message object 29 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 30:
/// -----------------------------------------------------------------------
/// - message object 30 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 31:
/// -----------------------------------------------------------------------
/// - message object 31 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 32:
/// -----------------------------------------------------------------------
/// - message object 32 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 33:
/// -----------------------------------------------------------------------
/// - message object 33 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 34:
/// -----------------------------------------------------------------------
/// - message object 34 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 35:
/// -----------------------------------------------------------------------
/// - message object 35 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 36:
/// -----------------------------------------------------------------------
/// - message object 36 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 37:
/// -----------------------------------------------------------------------
/// - message object 37 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 38:
/// -----------------------------------------------------------------------
/// - message object 38 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 39:
/// -----------------------------------------------------------------------
/// - message object 39 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 40:
/// -----------------------------------------------------------------------
/// - message object 40 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 41:
/// -----------------------------------------------------------------------
/// - message object 41 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 42:
/// -----------------------------------------------------------------------
/// - message object 42 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 43:
/// -----------------------------------------------------------------------
/// - message object 43 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 44:
/// -----------------------------------------------------------------------
/// - message object 44 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 45:
/// -----------------------------------------------------------------------
/// - message object 45 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 46:
/// -----------------------------------------------------------------------
/// - message object 46 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 47:
/// -----------------------------------------------------------------------
/// - message object 47 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 48:
/// -----------------------------------------------------------------------
/// - message object 48 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 49:
/// -----------------------------------------------------------------------
/// - message object 49 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 50:
/// -----------------------------------------------------------------------
/// - message object 50 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 51:
/// -----------------------------------------------------------------------
/// - message object 51 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 52:
/// -----------------------------------------------------------------------
/// - message object 52 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 53:
/// -----------------------------------------------------------------------
/// - message object 53 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 54:
/// -----------------------------------------------------------------------
/// - message object 54 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 55:
/// -----------------------------------------------------------------------
/// - message object 55 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 56:
/// -----------------------------------------------------------------------
/// - message object 56 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 57:
/// -----------------------------------------------------------------------
/// - message object 57 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 58:
/// -----------------------------------------------------------------------
/// - message object 58 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 59:
/// -----------------------------------------------------------------------
/// - message object 59 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 60:
/// -----------------------------------------------------------------------
/// - message object 60 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 61:
/// -----------------------------------------------------------------------
/// - message object 61 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 62:
/// -----------------------------------------------------------------------
/// - message object 62 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 63:
/// -----------------------------------------------------------------------
/// - message object 63 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 64:
/// -----------------------------------------------------------------------
/// - message object 64 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 65:
/// -----------------------------------------------------------------------
/// - message object 65 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 66:
/// -----------------------------------------------------------------------
/// - message object 66 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 67:
/// -----------------------------------------------------------------------
/// - message object 67 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 68:
/// -----------------------------------------------------------------------
/// - message object 68 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 69:
/// -----------------------------------------------------------------------
/// - message object 69 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 70:
/// -----------------------------------------------------------------------
/// - message object 70 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 71:
/// -----------------------------------------------------------------------
/// - message object 71 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 72:
/// -----------------------------------------------------------------------
/// - message object 72 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 73:
/// -----------------------------------------------------------------------
/// - message object 73 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 74:
/// -----------------------------------------------------------------------
/// - message object 74 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 75:
/// -----------------------------------------------------------------------
/// - message object 75 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 76:
/// -----------------------------------------------------------------------
/// - message object 76 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 77:
/// -----------------------------------------------------------------------
/// - message object 77 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 78:
/// -----------------------------------------------------------------------
/// - message object 78 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 79:
/// -----------------------------------------------------------------------
/// - message object 79 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 80:
/// -----------------------------------------------------------------------
/// - message object 80 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 81:
/// -----------------------------------------------------------------------
/// - message object 81 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 82:
/// -----------------------------------------------------------------------
/// - message object 82 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 83:
/// -----------------------------------------------------------------------
/// - message object 83 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 84:
/// -----------------------------------------------------------------------
/// - message object 84 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 85:
/// -----------------------------------------------------------------------
/// - message object 85 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 86:
/// -----------------------------------------------------------------------
/// - message object 86 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 87:
/// -----------------------------------------------------------------------
/// - message object 87 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 88:
/// -----------------------------------------------------------------------
/// - message object 88 is not valid
/// -----------------------------------------------------------------------
/// Configuration of Message Object 89:
/// -----------------------------------------------------------------------