1. MSCAN initialization process
Check whether it has entered the initialization state. If not, enter the initialization state.
The CANCTL0 register needs to be set here.
Set the CAN baud rate.
The CANBTR0 and CANBTR1 registers need to be set here.
Set the corresponding CAN port filter.
The CANIDMR register needs to be set here.
Enable the MSCAN module and set the MSCAN clock source.
The CANCTL1 register needs to be set here.
Leave the initialization state and return to normal operation mode.
The CANCTL0 register needs to be set here.
Set the receive interrupt enable.
The CANRIER register needs to be set here.
2. Introduction to MSCAN initialization registers
3. CAN initialization configuration specific program implementation
/****************************************************************/
/* Initialize CAN0 */
/****************************************************************/
void INIT_MSCAN0(void)
{
if(CAN0CTL0_INITRQ==0) // Check whether it has entered the initialization state
CAN0CTL0_INITRQ =1; // Enter the initialization state
while (CAN0CTL1_INITAK==0); //Wait to enter the initialization state
CAN0BTR0_SJW = 0; //Set synchronization
CAN0BTR0_BRP = 7; //Set the baud rate, the pre-scaling factor is 8
CAN0BTR1 = 0x49; //TSEG1 is 10 time quanta, TSEG2 is 5 time quanta,
//MSCAN baud rate is 32MHz/8/(1+10+5)=250kHz
// Turn off the filter
CAN0IDMR0 = 0xFF;
CAN0IDMR1 = 0xFF;
CAN0IDMR2 = 0xFF;
CAN0IDMR3 = 0xFF;
CAN0IDMR4 = 0xFF;
CAN0IDMR5 = 0xFF;
CAN0IDMR6 = 0xFF;
CAN0IDMR7 = 0xFF;
CAN0CTL1 = 0xC0; // Enable the MSCAN module, the MSCAN clock source is the CAN bus clock
//CAN bus clock frequency is 32MHz
CAN0CTL0 = 0x00; //Return to normal operation mode
while(CAN0CTL1_INITAK); //Wait to return to normal operation mode
while(CAN0CTL0_SYNCH==0); //Wait for bus clock synchronization
CAN4RFLG_RXF = 1; // Clear the message receiving buffer
CAN0RIER_RXFIE = 1; //Enable receive interrupt
}
Previous article:Freescale MC9S12X: CAN Receive Configuration
Next article:Freescale MC9S12X Time Output Comparison
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- MSP430F2001IPW
- Analysis of ST MCU Model Rules
- Xunwei IMX6ULL development board builds a web server
- Where exactly is China leading in 5G?
- Audi car engine regularly stops and cannot start. Oscilloscope detection solution
- FPGA design ideas and techniques: data interface synchronization
- After __wfi is run, is the MCU still running the code?
- CC2640 Questions and Answers
- Who is the source manufacturer of the 3651 orthogonal convex tooth sensor? Is there anyone who can be its agent?
- Which is faster for switching, MOS or Darlington?