?? main.lst
字號:
ANSI-C/cC++ Compiler for HC12 V-5.0.30 Build 6037, Feb 7 2006
1: /*
2: * Copyright (c) 2004, Freescale Semiconductor
3: * Freescale Willy Note
4: *
5: * File name : main.c
6: * Project name: MSCAN12_DP256
7: *
8: * Author : Rebeca Delgado
9: * Department : RTAC Americas
10: *
11: * Description : a brief description of the module.
12: * Another line of the description.
13: *
14: * History :
15: * 21/07/2004 : Initial Development. (A10021)
16: */
17:
18: #include <hidef.h> /* for EnableInterrupts macro */
19: #include <mc9s12dp256.h> /* include peripheral declarations */
20:
21: #pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
22:
23: /* ID Definition */
24: #define ST_ID_100 0x20000000 /* Standard Id 0x100 formatted to be loaded
25: * in IDRx Registers in Tx Buffer
26: */
27:
28: /* Acceptance Code Definitions */
29: #define ACC_CODE_ID100 0x2000
30: #define ACC_CODE_ID100_HIGH ((ACC_CODE_ID100&0xFF00)>>8)
31: #define ACC_CODE_ID100_LOW (ACC_CODE_ID100&0x00FF)
32:
33:
34: /* Mask Code Definitions */
35: #define MASK_CODE_ST_ID 0x0007
36: #define MASK_CODE_ST_ID_HIGH ((MASK_CODE_ST_ID&0xFF00)>>8)
37: #define MASK_CODE_ST_ID_LOW (MASK_CODE_ST_ID&0xFF)
38:
39: /* Error Flags Definition */
40: #define NO_ERR 0x00
41: #define ERR_BUFFER_FULL 0x80
42:
43: /* Functions Prototypes */
44: void CANInit(void);
45: unsigned char CAN0SendFrame(unsigned long id, unsigned char priority, unsigned char length, unsigned char *txdata );
46: void Delay(void);
47:
48: void main () {
Function: main
Source : E:\Freescale\code\MSCAN12_DP256\Sources\main.c
Options : -BfaGapLimitBits-1 -Env"GENPATH=E:\Freescale\code\MSCAN12_DP256;E:\Freescale\code\MSCAN12_DP256\bin;E:\Freescale\code\MSCAN12_DP256\prm;E:\Freescale\code\MSCAN12_DP256\cmd;E:\Freescale\code\MSCAN12_DP256\Sources;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\lib;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\src;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -Env"LIBPATH=D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -EnvOBJPATH=E:\Freescale\code\MSCAN12_DP256\bin -EnvTEXTPATH=E:\Freescale\code\MSCAN12_DP256\bin -Lasm=%n.lst -Mb -ObjN=E:\Freescale\code\MSCAN12_DP256\MSCAN12_DP256_Data\P&E_ICD\ObjectCode\main.c.o -WmsgSd1106
0000 1b96 [2] LEAS -10,SP
49:
50: unsigned char errorflag = NO_ERR;
0002 6989 [2] CLR 9,SP
51: unsigned char txbuff[] = "ABCDEFGH";
0004 c641 [1] LDAB #65
0006 6b80 [2] STAB 0,SP
0008 52 [1] INCB
0009 6b81 [2] STAB 1,SP
000b 52 [1] INCB
000c 6b82 [2] STAB 2,SP
000e 52 [1] INCB
000f 6b83 [2] STAB 3,SP
0011 52 [1] INCB
0012 6b84 [2] STAB 4,SP
0014 52 [1] INCB
0015 6b85 [2] STAB 5,SP
0017 52 [1] INCB
0018 6b86 [2] STAB 6,SP
001a 52 [1] INCB
001b 6b87 [2] STAB 7,SP
001d 6988 [2] CLR 8,SP
52:
53: CANInit(); /* Initialize MSCAN12 Module */
001f 4a000000 [7] CALL CANInit,PAGE(CANInit)
54:
55: while(!(CAN0CTL0&0x10)); /* Wait for Synchronization */
0023 1f000010fb [5] BRCLR _CAN0CTL0,#16,*+0 ;abs = 0023
56:
57: CAN0RFLG = 0xC3; /* Reset Receiver Flags
0028 cc01c3 [2] LDD #451
002b 7b0000 [3] STAB _CAN0RFLG
58: *
59: * 0b11000011
60: * ||||||||__ Receive Buffer Full Flag
61: * |||||||___ Overrun Interrupt Flag
62: * ||||||____
63: * |||||_____>- Transmitter Status Bits
64: * ||||______
65: * |||_______>- Receiver Status Bits
66: * ||________ CAN Status Change Interrupt Flag
67: * |_________ Wake-Up Interrupt Flag
68: */
69:
70: CAN0RIER = 0x01; /* Enable Receive Buffer Full Interrupt
002e 7a0000 [3] STAA _CAN0RIER
71: *
72: * 0b00000001
73: * ||||||||__ Receive Buffer Full Int enabled
74: * |||||||___ Overrun Int disabled
75: * ||||||____
76: * |||||_____>- Tx Status Change disabled
77: * ||||______
78: * |||_______>- Rx Status Change disabled
79: * ||________ Status Change Int disabled
80: * |_________ Wake-Up Int disabled
81: */
82:
83:
84:
85:
86:
87: EnableInterrupts;
0031 10ef [1] CLI
88:
89: for (;;) {
90: errorflag = CAN0SendFrame((ST_ID_100), 0x00, sizeof(txbuff)-1, txbuff);
0033 c7 [1] CLRB
0034 87 [1] CLRA
0035 3b [2] PSHD
0036 8620 [1] LDAA #32
0038 3b [2] PSHD
0039 37 [2] PSHB
003a c608 [1] LDAB #8
003c 37 [2] PSHB
003d 1a86 [2] LEAX 6,SP
003f b754 [1] TFR X,D
0041 4a000000 [7] CALL CAN0SendFrame,PAGE(CAN0SendFrame)
0045 1b86 [2] LEAS 6,SP
0047 6b89 [2] STAB 9,SP
91: Delay();
0049 4a000000 [7] CALL Delay,PAGE(Delay)
004d 20e4 [3] BRA *-26 ;abs = 0033
92: }
93:
94: }
95:
96: /*
97: * CANInit: a description of the function functionName.
98: *
99: * Bit Timing Definitions
100: * ----------------------
101: *
102: * CAN Clock Source (External oscillator) = 16Mhz
103: * BitRate = 125Khz
104: * Total Time Quanta = 16
105: * Sincronization Jump Width = 4 Time Quanta
106: * 1 sample
107: * Sample point at 75% of Bit Timing
108: *
109: * CAN_BRP = ((CAN Clock Source)/fTq) - 1
110: * fTq = (Bit Rate) * (Total Time Quanta)
111: * Total Time Quanta = (SYNCH_SEG+(TSEG1+1)+(TSEG2+1))
112: * Total Time Quanta = 1 + 11 + 4 = 16 Time Quanta
113: * fTq = 125Khz * 16 Time Quanta = 2Mhz
114: * CAN_BRP = (16Mhz/2Mhz) - 1 = 8 - 1 = 7
115: * TSEG1 = 10
116: * TSEG2 = 3
117: * SJW = (Synchronization Jump Width-1) = 3
118: *
119: * Another line of the description.
120: *
121: * Parameters: None
122: *
123: * Return : None
124: */
125:
126: void CANInit(void) {
Function: CANInit
Source : E:\Freescale\code\MSCAN12_DP256\Sources\main.c
Options : -BfaGapLimitBits-1 -Env"GENPATH=E:\Freescale\code\MSCAN12_DP256;E:\Freescale\code\MSCAN12_DP256\bin;E:\Freescale\code\MSCAN12_DP256\prm;E:\Freescale\code\MSCAN12_DP256\cmd;E:\Freescale\code\MSCAN12_DP256\Sources;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\lib;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\src;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -Env"LIBPATH=D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -EnvOBJPATH=E:\Freescale\code\MSCAN12_DP256\bin -EnvTEXTPATH=E:\Freescale\code\MSCAN12_DP256\bin -Lasm=%n.lst -Mb -ObjN=E:\Freescale\code\MSCAN12_DP256\MSCAN12_DP256_Data\P&E_ICD\ObjectCode\main.c.o -WmsgSd1106
127:
128: CAN0CTL0 = 0x01; /* Enter Initialization Mode
0000 c601 [1] LDAB #1
0002 7b0000 [3] STAB _CAN0CTL0
129: *
130: * 0b00000001
131: * ||||||||__ Enter Initialization Mode
132: * |||||||___ Sleep Mode Request bit
133: * ||||||____ Wake-Up disabled
134: * |||||_____ Time stamping disabled
135: * ||||______ Synchronized Status
136: * |||_______ CAN not affected by Wait
137: * ||________ Receiver Active Status bit
138: * |_________ Received Frame Flag bit
139: */
140:
141: while (!(CAN0CTL1&0x01)){}; /* Wait for Initialization Mode acknowledge
0005 1f000001fb [5] BRCLR _CAN0CTL1,#1,*+0 ;abs = 0005
142: * INITRQ bit = 1
143: */
144:
145: CAN0CTL1 = 0xA0; /* Enable MSCAN module and LoopBack Mode
000a ccc7a0 [2] LDD #51104
000d 7b0000 [3] STAB _CAN0CTL1
146: *
147: * 0b10100000
148: * ||||||||__ Initialization Mode Acknowledge
149: * |||||||___ Sleep Mode Acknowledge
150: * ||||||____ Wake-up low-pass filter disabled
151: * |||||_____ Unimplemented
152: * ||||______ Listen Only Mode disabled
153: * |||_______ Loop Back Mode enabled
154: * ||________ Ext Osc/Xtal as Clock Source
155: * |_________ MSCAN Module enabled
156: */
157:
158: CAN0BTR0 = 0xC7; /* Synch Jump = 3 Tq clock Cycles
0010 7a0000 [3] STAA _CAN0BTR0
159: *
160: * 0b11000111
161: * ||||||||__
162: * |||||||___\
163: * ||||||____ |
164: * |||||_____ |_ CAN Clock Prescaler = 7
165: * ||||______ |
166: * |||_______ |
167: * ||________/
168: * |_________>- SJW = 3
169: */
170:
171: CAN0BTR1 = 0x3A; /* Set Number of samples per bit, TSEG1 and TSEG2
0013 c63a [1] LDAB #58
0015 7b0000 [3] STAB _CAN0BTR1
172: *
173: * 0b00111010
174: * ||||||||__
175: * |||||||___|
176: * ||||||____|- TSEG1 = 10
177: * |||||_____|
178: * ||||______
179: * |||_______\_ TSEG2 = 3
180: * ||________/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -