Hi, good morning,
I'm tryin to setup de flexcan in a MCU52255CAF. I have a problem setting the baud rate in the microcontroller. I've followed the chapter "32 Flexcan from MCF52259RM."
I can't communicate two devices over the can with MCF52259.
I configure the registers with the follow data.
Use external Clock of 25Mhz.
Ftq = 25 / (10 + 1) ; Preescaler: 10.(Eqn32-6)
BitRate : Ftq / ( 1 + 11 + 4) (Eqn32-7)
When I send data over the can, I meassure the wide of 1 bit with the osciloscope, and I get a wide of 25uS.
I change the preescaler, and always I get the same wide, I think that, i'm not configuring correctly the baudrate in the register.
What I'm doing wrong?
You should tell us the exact hex number that you're writing to CANCTRL so we can check your figures. If not you actual initialisation code.
You should also tell us your external crystal frequency, and what you have the internal Fsys running at, in case CLK_SRC is set wrong and you're using Fsys.
I assume by "external clock" you mean the crystal frequency, as there's no separate "external clock" that can be used for CAN on this chip.
Are you following "32.4"? You should only change the clock source when the controller is DISABLED. You should only change anything else in the configuration when the module is in FREEZE mode. The module may be ignoring your writes if you're writing to the registers when it is running. Have you tried reading them back after you've written them?
You are programming a bit rate of 25MHz/(10 * 16) or 156.25 kHz. That isn't a standard baud rate for CAN. The usual rates are 125, 250, 5000 and 1000 kHz. Are you sure that's what you want? If you're getting a 25us bit rate (40 kHz) and are programming 16 quanta/bit, then PRESDIV must be dividing by 39, so PRESDIV must be 38 (0x26).
> Ftq / ( 1 + 11 + 4)
I'd like to see PRESDIV, PSEG1, PSEG2, PROPSEG, RJW and CLK_SRC at a minimum. So what is CANCTRL?
Tom