EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: viperidae on September 28, 2020, 09:12:40 am
-
What am I doing wrong?
I've tried to read the KCAN bus on my car, which is supposedly 100Khz CAN 2.0. https://www.e90post.com/forums/showthread.php?t=177272 (https://www.e90post.com/forums/showthread.php?t=177272)
I've tried with both an MCP2551 + STM32F303RE and MCP2551 + MCP2515 + Arduino.
The best I can get in receive two corrupt looking frames, one in each buffer of the 2551.
[attach=1]
It's definitely 100kHz, but the voltages seem a bit weird.
It's going positive and negative.
I thought it was supposed to go between 0V and ~5V.
This point doesn't have a termination resistor, but there are several nodes on the bus and obviously they can all talk to each other fine, or
CH1 is connected between CANH and CANL, there is no common ground between the car and scope.
I've verified the crystal speed in the MCP2551 by enabling the clkout pin and measuring it at 8MHz.
I've got the following config registers set:
CANCTRL=0b1000000 - listen mode, clkout disabled
CNF1=0b00000100 - SJW=0, BRP=4
CNF2=0b10010000 - BLTMODE=1, PHSEG=2, PRSEG=0
CNF3=0b10000010 - SOF=1, PHSEG=2
That should add up to:
SyncSeg=1TQ
PropSeg=1TQ
PS1=3TQ
PS2=3TQ
Total bit time of 8TQ
8MHz clock with a BRP of 4 gives a TQ of ((2*(BRP+1))/8000000 = 1.25uS
8TQ * 1.25uS = 100KHz
I know the registers are all set as expected, since I can read them back out.
I wasted Saturday trying to get this going on the STM32 and wasted Sunday with the Arduino.
I don't have any other types of CAN transceivers to try. I was using a DIP8
One of the modules uses a TJA1054T
[attach=2]
These are my dodgy MCP devices I've been using
[attach=3]
(looks like the "Insert attachment in the message" feature doesn't work too well...)
Edit: I'm an idiot. I was adamant I had CANH and CANL around the right way, but after staring at the scope image and checking which wire I probed as ground, the "fall time" was too sharp for a return-to-zero receiisive bit and the "rise time" was too sloppy for a dominant bit.
Swapped the wires and now my interrupt led is flashing like crazy.
-
When the CAN bus is not driven, both wires are floating, (and pulled to each other with the termination resistors)
You can add a few bias resistors (10k to 1Meg or so) to the wires to give them a bias voltage of half Vcc. This may make fault finding with a scope a bit easier.
It also makes the signals a bit more symmetrical, which may be (a bit) better for EMC reasons, but probably not terribly important.