Open Mike4U opened 8 years ago
Closed issue #10 prematurely accidentally but will leave as is for now.
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
Hello Mike, how did you calculate the values for 33333 bps?
Thanks..
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.
Sorry didn't want to close (again)
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
Added the General Motors SWCAN (Single Wire CAN) bus speed. Added the part used to test on a Chevy SparkEV