Good afternoon,
I have some difficulties to configure CAN Bus Timing.
My clock source is configured at 4MHz. The configuration used in freescale example give me a CAN Bus Timing to 500kbp/s.
I would like to upgrade this speed to 1Mbit/s.
I try some example to modify Time Segment Values and prescaler, but it don't works for now.
That's why I required your help.
Best Regards,
Here the example of CAN Initilisation :
void vfnCAN_Init(void) { CAN0CTL0 = 0x01; /* MSCAN in initialization mode */ while (!(CAN0CTL1_INITAK)) ; /* Wait for initialization mode acknowledge */ CAN0CTL1_CANE = 1; /* Enable MSCAN module */ CAN0CTL1_CLKsrc=0; /* Clock source is OSCCLK, CANCLK = 4MHz */ CAN0CTL1_LOOPB = 0; /* Set to 1 for LoopBack Mode, 0 otherwise */ CAN0CTL1_LISTEN = 0; /* Not listen only mode */ /* Baud rate = CANCLK/(Prescaler * time quantas) */ CAN0BTR1_TSEG_10 = 0x04; /* Time Segment 1 = 5 */ CAN0BTR1_TSEG_20 = 0x01; /* Time Segment 2 = 2 */ /* TSEG1 + TSEG2 + SYNCH_SEG = 8 time quantas */ /* Prescaler = CANCLK/(Baud rate * time quantas) = 4MHz/(500kHz * 8) = 1 */ CAN0BTR0_BRP = 0x00; /* Baud rate prescaler = 1 */ CAN0BTR0_SJW = 0x01; /* Sinchronization jump width = 2 clock cycles */ CAN0BTR1_SAMP = 0; /* One sample per bit */ CAN0IDAC_IDAM = 0x01; /* Four 16-bit acceptance filters */ CAN0IDAR0 = 0xFF; /* 16 bit Filter 0 */ CAN0IDMR0 = 0xFF; /* No Filter */ CAN0IDAR1 = 0xFF; CAN0IDMR1 = 0xFF; CAN0IDAR2 = 0xFF; /* 16 bit Filter 1 */ CAN0IDMR2 = 0xFF; /* No Filter */ CAN0IDAR3 = 0xFF; CAN0IDMR3 = 0xFF; CAN0IDAR4 = 0xFF; /* 16 bit Filter 2 */ CAN0IDMR4 = 0xFF; /* No Filter */ CAN0IDAR5 = 0xFF; CAN0IDMR5 = 0xFF; CAN0IDAR6 = 0xFF; /* 16 bit Filter 3 */ CAN0IDMR6 = 0xFF; /* No Filter */ CAN0IDAR7 = 0xFF; CAN0IDMR7 = 0xFF; CAN0CTL0 = 0x00; /* Exit initialization mode request */ while (CAN0CTL1_INITAK) ; /* Wait for normal mode */ while(!(CAN0CTL0_SYNCH)) ; /* Wait for CAN synchronization */ CAN0RFLG_RXF = 1; /* Clear receiver flags */ CAN0RIER_RXFIE = 1; /* Enable Full Receive Buffer interrupt */ }