void MSCANInit(void)
{
// If MSCAN peripheral is not in Initialization Mode, enables the Inizialization Mode Request
if(!(CANCTL1&CANCTL1_INITAK_MASK))
{
CANCTL0 = CANCTL0_INITRQ_MASK;
while(!(CANCTL1&CANCTL1_INITAK_MASK))
;
}
// Enables MSCAN peripheral and chooses Oscillator Clock, Loop Disabled and Normal Operation
CANCTL1 = 0x80;
// Configures SJW = 3Tq and Prescaler = 3
CANBTR0 = 0x82;
// Configures One Sample, Time Segment 1 = 6Tq and Time Segment 2 = 3Tq
CANBTR1 = 0x25;
CANIDAC = 0x0;
// Disables all the Filters
CANIDMR_1B+0 = 0xFF;
CANIDMR_1B+1 = 0xFF;
CANIDMR_1B+2 = 0xFF;
CANIDMR_1B+3 = 0xFF;
CANIDMR_2B+0 = 0xFF;
CANIDMR_2B+1 = 0xFF;
CANIDMR_2B+2 = 0xFF;
CANIDMR_2B+3 = 0xFF;
// Restarts MSCAN peripheral and waits for Initialization Mode exit
CANCTL0 = 0x00;
while(CANCTL1&CANCTL1_INITAK_MASK)
;
// Waits for MSCAN synchronization with the CAN bus
while(!(CANCTL0&CANCTL0_SYNCH_MASK))
;
}
这是我的初始化程序,两个节点一样。我想获得125K的波特率,不知道这样设置行吗? |