mdu_conf.lst
来自「菜鸟,详细NRF24E1运用,程序,电路」· LST 代码 · 共 195 行
LST
195 行
C51 COMPILER V9.00 MDU_CONF 11/13/2010 14:45:59 PAGE 1
C51 COMPILER V9.00, COMPILATION OF MODULE MDU_CONF
OBJECT MODULE PLACED IN mdu_conf.OBJ
COMPILER INVOKED BY: D:\Program Files\KEIL C V4\C51\BIN\C51.EXE mdu_conf.c BROWSE DEBUG OBJECTEXTEND
line level source
*** WARNING C500 IN LINE 1 OF MDU_CONF.C: LICENSE ERROR (R208: RENEW LICENSE ID CODE (LIC))
1
2 #include "reg24le1.h"
3 #include "mdutest.h"
4
5 /*函数定义部分*/
6
7 #define toasc(x) (x+'0') //数字转换成对应的ASC码
8 #define UPtoLOW(x) (x-'A'+'a') //大写转换成小写
9 #define LOWtoUP(x) (x-'a'+'A') //小写转换成大写
10
11 /*软件延时函数*/
12 void delay(unsigned int dj)
13 {
14 1 unsigned char di;
15 1 for(;dj>0;dj--)
16 1 for(di=120;di>0;di--)
17 1 {
18 2 ;
19 2 }
20 1
21 1 }
22 /*led灯的输出配置*/
23 void ioconfig()
24 {
25 1 P1DIR&=0XFE; //配置GPIO为输出
26 1 P10=0;
27 1 }
28
29
30 /*串口初始化化*/
31 void uart()
32 {
33 1 CLKCTRL = 0x28; // MCU时钟设置16M
34 1 CLKLFCTRL = 0x01; // 设置32.768K时钟
35 1
36 1 P0DIR &= 0xF7; // P03 (TxD) 输出
37 1 P0DIR |= 0x10; // P04 (RxD) 输入
38 1 P0|=0x18;
39 1
40 1 S0CON = 0x50;
41 1 PCON |= 0x80; //倍增
42 1 WDCON |= 0x80; // 选择内部波特率发生器
43 1
44 1 S0RELL = 0xFB;
45 1 S0RELL = 0xF3; //波特率设置为38400
46 1 }
47
48 /*发送一个字符*/
49
50 void putch(char ch)
51 {
52 1 S0BUF=ch;
53 1 while(!TI0);
54 1 TI0=0;
C51 COMPILER V9.00 MDU_CONF 11/13/2010 14:45:59 PAGE 2
55 1 }
56
57 /*发送一个字符串*/
58 void puts(char *str)
59 {
60 1 while(*str!='\0')
61 1 {
62 2 putch(*str++);
63 2 }
64 1 }
65
66 /*MDU16bit乘法*/
67 unsigned int MDUmul_16bit(unsigned int x1,unsigned int x2)
68 {
69 1 unsigned int res=0;
70 1 MD0=x1&0xff; //写入低8bit
71 1 MD4=x2&0xff;
72 1 MD1=((x1&0xff00)>>8);
73 1 MD5=((x2&0xff00)>>8);
74 1 delay(10);
75 1 res+=MD0;
76 1 res+=MD3*256; ;
77 1 return res;
78 1 }
79 //16bit的除法
80 void MDUdiv_16bit(unsigned int x1,unsigned int x2,unsigned int *Quotient,unsigned int* Remainder )
81 {
82 1
83 1 *Quotient=0;
84 1 *Remainder=0;
85 1 MD0=x1&0xff; //写入低8bit
86 1 MD1=((x1&0xff00)>>8);
87 1 MD4=x2&0xff;
88 1 MD5=((x2&0xff00)>>8);
89 1 delay(10);
90 1 *Quotient=MD0+MD1*256;// 商
91 1 *Remainder+=MD4;
92 1 *Remainder+=MD5*256; //余数
93 1 }
94
95 //32bit的除法
96 void MDUdiv_32bit(unsigned int x1,unsigned int x2,unsigned int *Quotient,unsigned int* Remainder )
97 {
98 1
99 1 *Quotient=0;
100 1 *Remainder=0;
101 1 MD0=x1&0xff; //写入低8bit
102 1 MD1=(x1>>8)&0xff;
103 1 MD2=(x1>>16)&0xff;
104 1 MD3=(x1>>24)&0xff; //写入最高的8位
105 1 MD4=x2&0xff;
106 1 MD5=(x2>>8)&0xff;
107 1 delay(10);
108 1 *Quotient=MD0+MD3*256;// 商
109 1 *Remainder+=MD4;
110 1 *Remainder+=MD5*256; //余数
111 1 }
112
113 //移位函数
114 unsigned int shiffunc(unsigned int dat,unsigned char bitnum,unsigned char derec)
115 {
116 1 unsigned int res=0;
C51 COMPILER V9.00 MDU_CONF 11/13/2010 14:45:59 PAGE 3
117 1 MD0=dat&0xff; //dat的LSB的提取
118 1 MD3=(dat>>8)&0xff;//dat的MSB提取
119 1 if(derec==LEFT)
120 1 ARCON&=~(0x20);//左移
121 1 else
122 1 ARCON|=(0x20); //右移
123 1 ARCON|=bitnum; //bit0-bit4决定移位的位数
124 1 delay(5);
125 1 res+=MD0;
126 1 res+=MD3*256; //高8位
127 1 return res;
128 1 }
129
130 //显示函数将数字分解成4位的ASC码发送给超级终端
131 void display(unsigned int x)
132 {
133 1 unsigned char buf[8]; //存储分离的位的数组定义
134 1 unsigned char bitw=0;
135 1 unsigned char tmph=0,tmpl=0;
136 1 while(x)
137 1 {
138 2 buf[bitw++]=x&0xff; //数据以8位分离出来
139 2 x>>=8;
140 2 }
141 1 if(bitw==0)
142 1 {
143 2 putch('\n');
144 2 puts(" the res=="); //显示数据输出的头
145 2 putch(toasc(0));
146 2 }
147 1 else
148 1 {
149 2 while(bitw) //有效位宽判断
150 2 {
151 3 putch('\n');
152 3 puts(" the res==0x"); //显示数据输出的头
153 3 if((buf[bitw-1]/16)>9) //已经超出10
154 3 {tmph=(buf[bitw-1]/16)-10+'a'; } //转成16进制字母显示
155 3 else
156 3 {putch(toasc(buf[bitw-1]/16)); } //如果没有超出就10进制数字显示
157 3 if((buf[bitw-1]%16)>9)
158 3 {tmph=(buf[bitw-1]%16)-10+'a'; }
159 3 else
160 3 {putch(toasc(buf[bitw-1]%16)); }
161 3 bitw--;
162 3 }
163 2 }
164 1 putch('\n'); //换行
165 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 542 ----
CONSTANT SIZE = 24 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 32
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?