teachop / FlexCAN_Library

Arduino library for CAN on Teensy 3.1
The Unlicense
155 stars 122 forks source link

Some changes. #17

Open xboxpro1 opened 8 years ago

xboxpro1 commented 8 years ago

Add more bus speed settings and change some functions. Add new functions. Bus speed settings are similar to the Can Bus Libary from Seeed Studio for the MCP2515. See "readme.md" All speed settings are tested and working. Use function connect() if you dont know the bus speed. If you want another speed, use the Excel sheet.

Mike4U commented 8 years ago

Just want to point out some observations on the can-timing spread sheet:

  1. Where is this from, its similar to CAN_setup1 but gets different results. Maybe I didn't setup everything.
  2. At all baud rates supported in the teachop branch the spreadsheet gets different results for RJW. I haven't tried the results in my 33333 baud Single Wire setup yet.
  3. What is the significance of the red OK> in column A? I noticed it's still there when I put in the RJW values from my 33333 and all teashop's speeds. Does that mean there ok too?
xboxpro1 commented 8 years ago

Hello,

  1. The Excel sheet CAN_setup1 is not for the MK20DX processor. But it is the same sheet. I have modified the calculations consistent with the MK20DX manual. You setup everything right.
  2. If you look into the manual https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf Chapter 44 CAN (FlexCAN) Page 1053 Field RJW Resync Jump Width = RJW + 1. Field PSEG2 Phase Buffer Segment 2 = (PSEG2 + 1) Page 1105 Figure 44-67. Segments within the bit time and page 1106 Table 44-80 CAN standard compliant bit time segment settings. If you have for example: Time Segment 2 = 4 --> PSEG2 = 3(page 1105 Figure 44-67) Time Segment 2 = 4 --> Resync Jump Width = 1 - 4 (page 1106 Table 44-80) --> RJW = Resync Jump Width - 1 (page 1105 Figure 44-67) so valid RJW value is from 0 to 3!!! I have found another pdf "FlexCAN_bit_timing" page 7 STEP 5. the writer has the highest RJW value chosen. You are right RJW value for 0 - 3 is correct. I think this is only important for resynchronization.
  3. The red OK> marks the columm when all values are correct. PRESDIV 0 - 255, PSEG1 0 - 7, PSEG2 1 - 7, PROPSEG 0 - 7, RJW 0 - 3, and your desired baud rate is correct. So RJW 0 - 3 are correct.(page 1053 - 1056). FlexCAN bit timing.pdf