CAN timing settings in C code

Universal Programmable Converter for CAN FD and CAN
Post Reply
cgmollo62
Posts: 10
Joined: Tue 28. Jun 2022, 13:06

CAN timing settings in C code

Post by cgmollo62 » Tue 28. Jun 2022, 13:12

Hi. The C_POWER_STATES example code has the following CAN timing settings string: _80M_500K_80____4M_80_ISO. I think the 80M is the clock speed and the 500K is the nominal bit rate. What are the other settings in this string? Thanks!

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: CAN timing settings in C code

Post by M.Maidhof » Wed 29. Jun 2022, 08:58

Hi,

please have a look in the can_user.h file for more details:

Code: Select all

#ifndef  _CAN_USER_H_
#define  _CAN_USER_H_


// Each single value listed here will be a 'true' value. If hardware needs a '-1' decrement this is done by CAN_Initialize().
//                                           clock                arbitration phase               misc               CAN-FD data phase
//    struct CANTiming_t = {                   can_clk,        brp, tseg1, tseg2, sjw,      limit, lo, mod,       brp, tseg1, tseg2, sjw  }
//                                         max. values:       1024,   256,   128, 128,        255,  1,   2,      1024,    32,    16,  16
#define	_80M___1M_80____4M_80_ISO		{ CAN_CLOCK_80M,          1,    63,    16,   1,         96,  0,   1,         1,    15,     4,   1}		// 80 MHz,   1M    80%,   4M 80%, ISO
#define	_80M_800K_80____4M_80_ISO		{ CAN_CLOCK_80M,          1,    79,    20,   1,         96,  0,   1,         1,    15,     4,   1}		// 80 MHz, 800K    80%,   4M 80%, ISO
#define	_80M_500K_80____4M_80_ISO		{ CAN_CLOCK_80M,          1,   127,    32,   1,         96,  0,   1,         1,    15,     4,   1}		// 80 MHz, 500K    80%,   4M 80%, ISO
#define	_80M_250K_80____2M_80_ISO		{ CAN_CLOCK_80M,          2,   127,    32,   1,         96,  0,   1,         2,    15,     4,   1}		// 80 MHz, 250K    80%,   2M 80%, ISO
#define	_80M_125K_80____2M_80_ISO		{ CAN_CLOCK_80M,          4,   127,    32,   1,         96,  0,   1,         4,     7,     2,   1}		// 80 MHz, 125K    80%,   2M 80%, ISO
#define	_80M_100K_80____1M_80_ISO		{ CAN_CLOCK_80M,          4,   159,    40,   1,         96,  0,   1,         4,    15,     4,   1}		// 80 MHz, 100K    80%,   1M 80%, ISO
#define	_80M__95K_80__500K_80_ISO		{ CAN_CLOCK_80M,          8,    83,    21,   1,         96,  0,   1,         8,    15,     4,   1}		// 80 MHz,  95K238 80%, 500K 80%, ISO
#define	_80M__83K_80__500K_80_ISO		{ CAN_CLOCK_80M,         16,    47,    12,   1,         96,  0,   1,        16,     7,     2,   1}		// 80 MHz,  83K333 80%, 500K 80%, ISO
#define	_80M__50K_80__500K_80_ISO		{ CAN_CLOCK_80M,         16,    79,    20,   1,         96,  0,   1,        16,     7,     2,   1}		// 80 MHz,  50K    80%, 500K 80%, ISO
#define	_80M__47K_80__500K_80_ISO		{ CAN_CLOCK_80M,         21,    63,    16,   1,         96,  0,   1,        16,     7,     2,   1}		// 80 MHz,  47K619 80%, 500K 80%, ISO
#define	_80M__33K_80__500K_80_ISO		{ CAN_CLOCK_80M,         24,    79,    20,   1,         96,  0,   1,        16,     7,     2,   1}		// 80 MHz,  33K333 80%, 500K 80%, ISO
regards

Michael

cgmollo62
Posts: 10
Joined: Tue 28. Jun 2022, 13:06

Re: CAN timing settings in C code

Post by cgmollo62 » Wed 29. Jun 2022, 15:12

Perfect. Thanks!

Post Reply