Hi,
I have the S12ZVC Evaluation board. I'm trying to get CAN working at 1 Mbit/ s baud rate; 500 kbit/s works fine, transmitting and receiving. I can even get 800 kbit/s; but I can't get 1000 kbit/s (1Mb/s).
I've tried using both Processor Expert and coding by hand - I can get the lower baud rates working by both methods. Processor expert sometimes says the baud rate is not achievable when you first start a project but if you save, exit and retry it lets you select 1Mb/s using high speed mode and the external clock.
When I run the project at 1000kbit/ s it doesn't send or receive; it's like CAN is off or the bus is off. I'm assuming it's because that baud rate is unachievable with this board but it should be.
There aren't many details that came with the board, like whether there is an external oscillator and what the clock rate is and I don't know which settings to use in processor expert: internal clock or external. Any help in configuring the clock and the registers would be appreciated..I'm attaching screen shots of my processor expert settings below.
Also, I'd prefer to do it by hand rather than processor expert: at least by hand, you get bus errors but it still transmits. With processor expert the tx is just dead.
Max
Solved! Go to Solution.
OK, got it, it works: because the ext crystal on the evaluation board is 4Mz, the correct settings are:
and, using the internal bus clock in the CAN timing high speed mode enables 1 Mbit/s to work correctly:
Hi Radek,
Yes you're absolutely right and that's great advice. I'm only using the evaluation board for testing; for production a faster clock would be required. Thanks for your help !
OK, got it, it works: because the ext crystal on the evaluation board is 4Mz, the correct settings are:
and, using the internal bus clock in the CAN timing high speed mode enables 1 Mbit/s to work correctly:
Hi Max,
I didn’t test it on HW.
You are right, the external crystal on board is just 4MHz.
I am afraid that 1Mbit/s bit rate is not possible to achieve with 4MHz clock source – It is out of CAN standard compliant bit time segment settings.
You should use at least 8MHz clock source for 1Mbit CAN bit rate.
So, you may use bus clock>=8MHz as CAN clock source for debugging purpose. However, I would like to strongly recommend use the external crystal with frequency 8MHz or more for real production and take this clock as CAN module clock source.
The PLL cannot fulfill CAN standard requirements for the clock source.
For example: for 8MHz clock source and described settings you need clock source with tolerance better than 0.48% …
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Radek and thanks for the answer - I tried your settings - well, as close to them as possible:
and:
And still get the same problem: messages are not transmitted and I'm assuming it's a timing error.
In your example, the ext clock frequency is 50 Mhz - that's not possible on the evaluation board is it ? The schematic for the evaluation board shows a 4 Mz crystal, are the setting different ? I can select a 4Mhz ext clock frequency in the CPU settings and then adjust the CAN timing settings but I get the same problem.
Hi Max,
As first, please go to CPU settings and select External Clock as the clock source for bus clock.
This will enable external oscillator (The external oscillator is disabled by default).
After that, please set Time segment 1 as 1, Time segment 2 as 4, RSJ as 2, One sample per bit:
Finally, please open Bit rate settings, select External Clock as CAN clock source and choose 1000kbit/s as bit rate.
Attached simple CAN bit rate calculator.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Update: I can now send CAN messages by switching on the physical layer:
#ifdef CP0CR
CP0CR_CPE = 1;
CP0CR_SPE = 0;
#endif
But the messages are still not being recognized at 1Mbit/s...also not receiving messages at 1 Mbit/ s either..