修改为250K-操控端

This commit is contained in:
2025-10-21 21:17:49 +08:00
parent 2153bfcd1b
commit 0bac0a1b23
5 changed files with 269 additions and 247 deletions

38
CAN.C
View File

@@ -150,19 +150,15 @@ void CAN_vInit(void)
/// General Configuration of the Node 0:
/// - set INIT and CCE
/// - enable interrupt generation upon a change of BOFF or EWARN or upon a
/// set of LLE, LOE or INIT
/// - alert interrupt node pointer: MultiCAN SRN 0
//-----------CAN_NCR0 = 0x00000049-------------------------------------
//-----------CAN_NCR0 = 0x00000041-------------------------------------
CAN_vWriteCANAddress(CAN_NCR0); // Addressing CAN_NCR0
CAN_DATA0 = 0x49; // load NODE 0 control register[7-0]
CAN_DATA0 = 0x41; // load NODE 0 control register[7-0]
CAN_vWriteEN(D0_VALID+ADR_INC); // Data0 is Valid for transmission and
// Write is EnabledCAN Address pointing
// to the CAN_NSR0.
// CAN Address pointing to the CAN_NIPR0
CAN_ADCON = ADR_INC; // Auto Increment the current address(+1)
@@ -198,15 +194,15 @@ void CAN_vInit(void)
/// Configuration of the Node 0 Baud Rate:
/// - required baud rate = 250.000 kbaud
/// - real baud rate = 250.000 kbaud
/// - sample point = 75.00 %
/// - there are 11 time quanta before sample point
/// - there are 4 time quanta after sample point
/// - sample point = 83.33 %
/// - there are 9 time quanta before sample point
/// - there are 2 time quanta after sample point
/// - the (re)synchronization jump width is 2 time quanta
//-----------CAN_NBTR0 = 0x00003A4B-------------------------------------
//-----------CAN_NBTR0 = 0x0000184F-------------------------------------
CAN_DATA0 = 0x4B; // load NBTR0_SJW, BRP
CAN_DATA1 = 0x3A; // load NBTR0_DIV8, TSEG2, TSEG1
CAN_DATA0 = 0x4F; // load NBTR0_SJW, BRP
CAN_DATA1 = 0x18; // load NBTR0_DIV8, TSEG2, TSEG1
CAN_vWriteEN(D0_VALID+D1_VALID+ADR_INC); // Data0, 1 are valid for
// transmission and Write is
// Enabled with Auto
@@ -401,11 +397,11 @@ void CAN_vInit(void)
/// - priority class 3; transmit acceptance filtering is based on the list
/// order (like class 1)
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x12000023
/// - identifier 29-bit: 0x11000023
//--------------MOAR6 = 0xF2000023---------------------------------------
//--------------MOAR6 = 0xF1000023---------------------------------------
CAN_vWriteAMData(0xF2000023); // load MO6 arbitration register
CAN_vWriteAMData(0xF1000023); // load MO6 arbitration register
// CAN Address pointing to the CAN_MODATAH6
CAN_ADCON = ADR_DEC; // Auto Decrement the current address(-1)
@@ -478,11 +474,11 @@ void CAN_vInit(void)
/// - priority class 3; transmit acceptance filtering is based on the list
/// order (like class 1)
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x11000123
/// - identifier 29-bit: 0x11000124
//--------------MOAR7 = 0xF1000123---------------------------------------
//--------------MOAR7 = 0xF1000124---------------------------------------
CAN_vWriteAMData(0xF1000123); // load MO7 arbitration register
CAN_vWriteAMData(0xF1000124); // load MO7 arbitration register
// CAN Address pointing to the CAN_MODATAH7
CAN_ADCON = ADR_DEC; // Auto Decrement the current address(-1)
@@ -710,11 +706,11 @@ void CAN_vInit(void)
/// - priority class 3; transmit acceptance filtering is based on the list
/// order (like class 1)
/// - extended 29-bit identifier
/// - identifier 29-bit: 0x12000024
/// - identifier 29-bit: 0x11000024
//--------------MOAR10 = 0xF2000024---------------------------------------
//--------------MOAR10 = 0xF1000024---------------------------------------
CAN_vWriteAMData(0xF2000024); // load MO10 arbitration register
CAN_vWriteAMData(0xF1000024); // load MO10 arbitration register
// CAN Address pointing to the CAN_MODATAH10
CAN_ADCON = ADR_DEC; // Auto Decrement the current address(-1)