FlexCAN_Library icon indicating copy to clipboard operation
FlexCAN_Library copied to clipboard

Added 33333 bps

Open Mike4U opened this issue 9 years ago • 6 comments

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

Mike4U avatar Feb 25 '16 20:02 Mike4U

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

Mike4U avatar Feb 26 '16 18:02 Mike4U

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

Mike4U avatar Mar 06 '16 20:03 Mike4U

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

Thanks..

xboxpro1 avatar Jun 08 '16 18:06 xboxpro1

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 avatar Jun 10 '16 03:06 Mike4U

Sorry didn't want to close (again)

Mike4U avatar Jun 10 '16 03:06 Mike4U

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

xboxpro1 avatar Jun 10 '16 08:06 xboxpro1