Skip to content

Conversation

@Mike4U
Copy link

@Mike4U Mike4U commented Feb 25, 2016

Added the General Motors SWCAN (Single Wire CAN) bus speed.
Added the part used to test on a Chevy SparkEV

Added the General Motors SWCAN (Single Wire CAN) bus speed.
@Mike4U
Copy link
Author

Mike4U commented Feb 26, 2016

Closed issue #10 prematurely accidentally but will leave as is for now.

@Mike4U
Copy link
Author

Mike4U commented Mar 6, 2016

Added some info on this to the Teensy and Chevy SparkEV forums.
https://forum.pjrc.com/threads/33306-SWCAN-bus-hack-allows-backup-camera-display?p=98031&viewfull=1#post98031

@xboxpro1
Copy link

xboxpro1 commented Jun 8, 2016

Hello Mike, how did you calculate the values for 33333 bps?

Thanks..

@Mike4U
Copy link
Author

Mike4U commented Jun 10, 2016

Sorry, back when I was working this I could have told you in painstaking detail but apparently did not properly document my procedure. (My early alzheimer's doesn't help)

I started with fnOptimalCAN_clock() which gave me bad results:
FLEXCAN0_CTRL1 = (FLEXCAN_CTRL_PROPSEG(7) | FLEXCAN_CTRL_RJW(2)
| FLEXCAN_CTRL_PSEG1(6) | FLEXCAN_CTRL_PSEG2(0) | FLEXCAN_CTRL_PRESDIV(19));
I think that violated some details in the kinetis CAN documentation.

I had previously been successful with an ArduinoDue using Collin Kidders DueCan library. It's a different chip with different registers and operation but the timing details should work out the same. So I iterated around somehow with part of fnOptimalCAN_clock() with the speeds that worked vs DueCan speeds to figure out a way that would solve for the difference and then for the 33333. Kind of a four equations four unknows where some of the unknowns were easily guessed from spec documents.
I don't know if it's optimal but has worked without a glitch for 3 months on a Checy SparkEV single wire bus.

@Mike4U Mike4U closed this Jun 10, 2016
@Mike4U Mike4U reopened this Jun 10, 2016
@Mike4U
Copy link
Author

Mike4U commented Jun 10, 2016

Sorry didn't want to close (again)

@xboxpro1
Copy link

Thanks for the reply, teachop calculate with Number of Time Quanta per Bit-time ->16.

clockspeed/(baud*Time Quanta per Bit-time) - FLEXCAN_CTRL_RJW = FLEXCAN_CTRL_PRESDIV

16Mhz / (250k*16) -1 = 3

I found an excel file on this page ...
https://community.nxp.com/thread/118136
and calculations on this page...
https://community.nxp.com/thread/109010

Maybe anyone have an excel file to calculate the values for the MK20DX256 Flexcan.
I dont want to guess..

Thanks ....
CAN_setup1.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants