Hello everyone,
I have a problem with baurate in classic CAN in S32K3. I reuse an example code "lwip_baremetal_s32k344" and add FlexCAN. Although I configed in clock diagram tab, FlexCAN tab and the S32DS also return the approriate value is 1 MHz (see the pictures below for more details), when I measured CAN_TX by logic analyzer, I see the baurate was just around 400Khz. Does anyone have the same problem with me? Thanks for your help.
已解决! 转到解答。
Hi@Andrew101
1. Regarding the CAN speed, as I mentioned, the CAN module configuration is correct, at 1M. You can check the ACK bit width; theoretically, it should be 1us. If it's not, check your MCU module.
(I can't run your code properly; I don't know why you're mixing MCAL and Drivers.)
2. Regarding the LPI2C speed, your "Clock_Ip_ReferencePoints" configuration is incorrect; the clock is not the I2C module's clock.
Of course,
Let me tell you again my problem. As you can see, in the configuration, the baurate is 1 Mbs, but when I measure on logic analyzer , the signal is just around 400 Kbs. Here are the picture and the whole project. I used on S32K344 EVB SCH 53148 Rev B board and s32ds 3.6.3, RTD 6.0.0
I think your measurement method is wrong.
You can use an oscilloscope to measure the minimum pulse width to calculate the bit rate.
In your configuration:
Tq = 5 / 80mhz = 62.5ns
CAN bit time = (1 + 8+ 5 + 2) * 62.5 = 1000ns
Bit rate = 1 / 1000ns = 1000K
Can you explain more details, please? I don't really understand. The configuration in the project I gave you is for 1000K. But the logic analyzer just recorded 400K. Additionally, when I debugged deeply into register, I saw a register CTRL1 with the field "PRESDIV" is set 4 but not 0. I don't know if it is the reason?
Hi@Andrew101
The 400k you are currently displaying is not necessarily a single bit width, it may be multiple bits wide.
"when I debugged deeply into register, I saw a register CTRL1 with the field "PRESDIV" is set 4 but not 0"
In your configuration, the "Prescaler division factor is 5", so the PRESDIV should be 5-1 = 4, so it's correct.
Hi@Andrew101
1. Regarding the CAN speed, as I mentioned, the CAN module configuration is correct, at 1M. You can check the ACK bit width; theoretically, it should be 1us. If it's not, check your MCU module.
(I can't run your code properly; I don't know why you're mixing MCAL and Drivers.)
2. Regarding the LPI2C speed, your "Clock_Ip_ReferencePoints" configuration is incorrect; the clock is not the I2C module's clock.