Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mcp2515 by
mcp2515_bittime.h
00001 /****************************************************************************** 00002 * 00003 * Controller Area Network (CAN) Demo-Application 00004 * Atmel AVR with Microchip MCP2515 00005 * 00006 * Copyright (C) 2005 Martin THOMAS, Kaiserslautern, Germany 00007 * <eversmith@heizung-thomas.de> 00008 * http://www.siwawi.arubi.uni-kl.de/avr_projects 00009 * 00010 ***************************************************************************** 00011 * 00012 * File : mcp2515_bittime.h 00013 * Version : 0.9 00014 * 00015 * Summary : MCP2515 CAN-timing values. Calculated with 00016 * a spreadsheet-based "Preprocessor" with information 00017 * from the MCP2515 and AT90CAN128 datasheets. 00018 * 00019 *****************************************************************************/ 00020 00021 #include "mcp2515_defs.h" 00022 00023 /*-----------------------*/ 00024 /* global settings */ 00025 /*-----------------------*/ 00026 00027 /* CFG3 */ 00028 00029 // Start of Frame SOF (CLKOUT) 00030 // either SOF_ENABLE or SOF_DISABLE 00031 #define MCP_GENERAL_SOF (SOF_DISABLE) 00032 00033 // Wake up Filter (WAKFIL) 00034 // either WAKFIL_ENABLE or WAKFIL_DISABLE 00035 #define MCP_GENERAL_WAKFIL (WAKFIL_DISABLE) 00036 00037 00038 /*-----------------------*/ 00039 /* 125 kBPS @ 4MHZ F_OSC */ 00040 /*-----------------------*/ 00041 00042 /* CNF1 */ 00043 00044 // SJW as defined in mcp_defs.h 00045 // here: SJW = 1*TQ 00046 #define MCP_4MHz_125kBPS_SJW (SJW1) 00047 00048 // Prescaler = (BRP+1)*2 00049 // here Prescaler = 4 -> BRP=1 00050 #define MCP_4MHz_125kBPS_BRP (1) 00051 00052 00053 /* CNF2 */ 00054 00055 // BLT-Mode defined in CNF3 (0 or BTLMODE from mcp_defs.h) 00056 #define MCP_4MHz_125kBPS_BLTMODE (BTLMODE) 00057 00058 // 3 samples (SAMPLE_3X) or 1 sample (SAMPLE_1X) 00059 #define MCP_4MHz_125kBPS_SAM (SAMPLE_1X) 00060 00061 // (Phase Segment 1) PHSEG1 = PS1 - 1 00062 // here: PS1 calculated as 2 00063 #define MCP_4MHz_125kBPS_PHSEG1 ((2-1)<<3) 00064 00065 // (Propagation Delay) PRSEG = PRSEQTQ-1 00066 // here PRSEQTQ = 2 00067 #define MCP_4MHz_125kBPS_PRSEG (2-1) 00068 00069 /* CNF3 */ 00070 00071 // (Phase Segment 2) PHSEG2 = PS2 - 1 00072 // here: PS2 calculated as 3 00073 #define MCP_4MHz_125kBPS_PHSEG (3-1) 00074 00075 00076 #define MCP_4MHz_125kBPS_CFG1 (MCP_4MHz_125kBPS_SJW | MCP_4MHz_125kBPS_BRP) 00077 #define MCP_4MHz_125kBPS_CFG2 (MCP_4MHz_125kBPS_BLTMODE | MCP_4MHz_125kBPS_SAM | MCP_4MHz_125kBPS_PHSEG1 | MCP_4MHz_125kBPS_PRSEG) 00078 #define MCP_4MHz_125kBPS_CFG3 (MCP_GENERAL_SOF | MCP_GENERAL_WAKFIL | MCP_4MHz_125kBPS_PHSEG) 00079 00080 00081 /*-----------------------*/ 00082 /* 20 kBPS @ 4MHZ F_OSC */ 00083 /*-----------------------*/ 00084 00085 /* CNF1 */ 00086 00087 // SJW as defined in mcp_defs.h 00088 // here: SJW = 1*TQ 00089 #define MCP_4MHz_20kBPS_SJW (SJW1) 00090 00091 // Prescaler = (BRP+1)*2 00092 // here Prescaler = 10 -> BRP=4 (20TQ) 00093 #define MCP_4MHz_20kBPS_BRP (4) 00094 00095 00096 /* CNF2 */ 00097 00098 // BLT-Mode defined in CNF3 (0 or BTLMODE from mcp_defs.h) 00099 #define MCP_4MHz_20kBPS_BLTMODE (BTLMODE) 00100 00101 // 3 samples (SAMPLE_1X) or 1 sample (SAMPLE_1X) 00102 #define MCP_4MHz_20kBPS_SAM (SAMPLE_1X) 00103 00104 // (Phase Segment 1) PHSEG1 = PS1 - 1 00105 // here: PS1 calculated as 8 00106 #define MCP_4MHz_20kBPS_PHSEG1 ((8-1)<<3) 00107 00108 // (Propagation Delay) PRSEG = PRSEQTQ-1 00109 // here PRSEQTQ = 3 00110 #define MCP_4MHz_20kBPS_PRSEG (3-1) 00111 00112 /* CNF3 */ 00113 00114 // (Phase Segment 2) PHSEG2 = PS2 - 1 00115 // here: PS2 calculated as 8 00116 #define MCP_4MHz_20kBPS_PHSEG (8-1) 00117 00118 00119 #define MCP_4MHz_20kBPS_CFG1 (MCP_4MHz_20kBPS_SJW | MCP_4MHz_20kBPS_BRP) 00120 #define MCP_4MHz_20kBPS_CFG2 (MCP_4MHz_20kBPS_BLTMODE | MCP_4MHz_20kBPS_SAM | MCP_4MHz_20kBPS_PHSEG1 | MCP_4MHz_20kBPS_PRSEG) 00121 #define MCP_4MHz_20kBPS_CFG3 (MCP_GENERAL_SOF | MCP_GENERAL_WAKFIL | MCP_4MHz_20kBPS_PHSEG)
Generated on Tue Jul 12 2022 22:54:59 by
1.7.2
