Configuring an MSCAN bus on the KE06Z: timing problems

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring an MSCAN bus on the KE06Z: timing problems

Jump to solution
397 Views
NNeff
Contributor III

I am trying to configure a KE06Z to talk on a CAN bus, and I'm getting error frames (reporting all types of errors, apparently randomly) and no messages (viewed with CANalyzer).  The bus is terminated at the ends with 120 ohm resistors.  Another device is broadcasting on the bus without problems or errors.  The bus rate is 250 kbit/s, therefore a bit should be taking 4 us, but is actually about 3.6 us long on the scope.  We wired up another board, and we're getting the same timing problems with it as well so it isn't a faulty transceiver on a particular KE06Z.

I've tried every valid combination of values for Time segment 1, Time segment 2, and Resync jump width (all 76 combinations) for 250 kbit/s, starting with letting the timing calculator choose those values for me, and I always get error frames. I've also tried auto initialization, and auto init plus enabled in init. code, and still get the error frames.  I've tried 500 kbit/s just to see if it made a difference and it doesn't; I need it to work at 250 kbit/s anyway because that's what the other device on the bus operates at.

I'm relatively new to both CAN and the KE06Z, so the problem might be something simple I suppose, but I'm at a loss. (I've attached a screen shot of the timing, initialization, and CPU clock/configuration set settings.)  Could it be a bug in CW for MCUs?  Any suggestions?

Labels (1)
0 Kudos
1 Solution
104 Views
NNeff
Contributor III

SOLVED! The CodeWarrior default for the setting for the external oscillator was 10 MHz, when the actually oscillator on the board is 8 MHz.  (I'm primarily a software engineer--it took the electronics guy to check that...:smileyblush:)

View solution in original post

0 Kudos
2 Replies
104 Views
NNeff
Contributor III

More info:  when I initialize and enable the CAN transceiver on the KE06Z but do not transmit anything, and my other device is transmitting by itself, the waveform is correct--each bit taking 4 usec. As soon as the KE06Z transmits a single message--for example, the address claim message--the bit length of the other device's transmissions' bits is reduced to 3.54 usec, and each transmission causes a error frame (although that device's messages do continue to appear in the CANalyzer trace).  So it's not something set wrong in CANalyzer, and it's something caused by the KE06Z's SendFrame() method or something associated with that message, since that's the only line I re-enabled in the KE06Z code.

Also, I discovered that the address claim message from the KE06Z will show up in the CANalyzer trace, if I leave the trace running as I start a new flash of the KE06Z.  It's as if something in the beginning of flashing a new image into the KE06Z flushes the MSCAN Tx buffer.  That first message sent is the only one that ever shows up, however, even if I've called SendFrame() with additional messages.  My additional messages are sent to the other device on the CAN bus, but are not received (or not received correctly), since the device does not do what the message commands it to.

When I enable the external oscillator and force the CAN bus to use that, and transmit a frame from the KE06Z, the error frames still occur but the single bit length is now stretched out to 5.06 usec, and the bus is behaving badly, with the difference between CAN HI and LO jumping up for parts of the bits on.  Again, if I only initialize and enable the KE06Z transceiver, with the timing set to use the external oscillator, but don't send anything, the bit duration in the messages from the other device is right where it should be at 4 usec.

0 Kudos
105 Views
NNeff
Contributor III

SOLVED! The CodeWarrior default for the setting for the external oscillator was 10 MHz, when the actually oscillator on the board is 8 MHz.  (I'm primarily a software engineer--it took the electronics guy to check that...:smileyblush:)

View solution in original post

0 Kudos