📄 cs5532.lst
字号:
C51 COMPILER V7.50 CS5532 03/16/2006 18:52:50 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE CS5532
OBJECT MODULE PLACED IN CS5532.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE CS5532.c LARGE BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <SST89x5xxRD2.h>
2 #include <intrins.h>
3 #include "Public.h"
4 #define CS5532_CS P3_4
5 #define RDYB P1_6
6
7 extern BYTE xdata RxdByte[15];
8
9 VOID SPI_init()
10 {
11 1 P1=0xf0;
12 1 SPCR=0x50; //Enable SPI
13 1 }
14
15 BYTE SPI_RW(BYTE Data)
16 {
17 1 BYTE temp;
18 1 SPDR=Data;
19 1 do
20 1 {
21 2 temp=SPSR&0x80;
22 2 }while(temp!=0x80);
23 1 SPSR&=0x7f; //Clear SPIF(Tx complete interrupt flag)
24 1 return SPDR;
25 1 }
26
27 VOID Read_Register(BYTE command)
28 {
29 1 INT8 j;
30 1 CS5532_CS=0;
31 1 _nop_();
32 1 _nop_();
33 1 SPI_RW(command);
34 1 for(j=0;j<4;j++)
35 1 RxdByte[j]=SPI_RW(0xfe);
36 1 _nop_();
37 1 _nop_();
38 1 CS5532_CS=1;
39 1 _nop_();
40 1 _nop_();
41 1 }
42
43 VOID Write_Register(BYTE command,BYTE top,BYTE high,BYTE mid,BYTE low)
44 {
45 1 CS5532_CS=0;
46 1 _nop_();
47 1 _nop_();
48 1 SPI_RW(command);
49 1 SPI_RW(top);
50 1 SPI_RW(high);
51 1 SPI_RW(mid);
52 1 SPI_RW(low);
53 1 _nop_();
54 1 _nop_();
55 1 CS5532_CS=1;
C51 COMPILER V7.50 CS5532 03/16/2006 18:52:50 PAGE 2
56 1 _nop_();
57 1 _nop_();
58 1 }
59
60 VOID CS5532_init()
61 {
62 1 SPI_init();
63 1 //Perform Hardware Reset
64 1 Write_Register(0xff,0xff,0xff,0xff,0xff);
65 1 Write_Register(0xff,0xff,0xff,0xff,0xff);
66 1 Write_Register(0xff,0xff,0xff,0xff,0xff);
67 1 Write_Register(0xff,0xff,0xff,0xff,0xfe);
68 1
69 1 //Perform Software Reset
70 1 Write_Register(0x03,0x20,0x00,0x00,0x00);
71 1
72 1 //Voltage Reference select
73 1 //Write Configuaration Registers Command,2.5<Vref<5V
74 1 Write_Register(0x03,0x00,0x00,0x00,0x00);
75 1
76 1 //Write Chnnel Setup Register 1 Command
77 1 //Select Chnnel 0,X=1
78 1 Write_Register(0x05,0x02,0x40,0x02,0x40);
79 1 }
80
81 VOID Self_Offset_Calibration()
82 {
83 1 CS5532_CS=0; //Lower chip select
84 1 _nop_();
85 1 _nop_();
86 1 SPI_RW(0x81); //Self offset calibration command
87 1 while(RDYB); //Wait for SDO to drop(P1.6)
88 1 _nop_();
89 1 _nop_();
90 1 CS5532_CS=1; //Raise chip select
91 1 _nop_();
92 1 _nop_();
93 1 }
94
95 VOID Self_Gain_Calibration()
96 {
97 1 CS5532_CS=0; //Lower chip select
98 1 _nop_();
99 1 _nop_();
100 1 SPI_RW(0x82); //Self offset calibration command
101 1 while(RDYB); //Wait for SDO to drop(P1.6)
102 1 _nop_();
103 1 _nop_();
104 1 CS5532_CS=1; //Raise chip select
105 1 _nop_();
106 1 _nop_();
107 1 }
108
109 VOID Single_Convert()
110 {
111 1 INT8 j;
112 1 CS5532_CS=0; //Lower chip select
113 1 _nop_();
114 1 _nop_();
115 1 SPI_RW(0x80); //Shift single convert command
116 1 while(RDYB); //Wait for SDO to drop(P1.6)
117 1 SPI_RW(0x00); //Shift out zeros to release SDO
C51 COMPILER V7.50 CS5532 03/16/2006 18:52:50 PAGE 3
118 1 for(j=0;j<3;j++)
119 1 RxdByte[j]=SPI_RW(0xfe);
120 1 SPI_RW(0xfe);
121 1 _nop_();
122 1 _nop_();
123 1 CS5532_CS=1; //Raise chip select
124 1 _nop_();
125 1 _nop_();
126 1 }
127
128 VOID Continuous_Convert_5_times()
129 {
130 1 INT8 i,j;
131 1 BYTE temp;
132 1 CS5532_CS=0; //Lower chip select
133 1 _nop_();
134 1 _nop_();
135 1 SPI_RW(0xc0); //Shift continuous convert command
136 1 for(i=0;i<5;i++) //Throw out 5 conversious-to flush residual filter
137 1 {
138 2 while(RDYB); //Wait for SDO to drop(P1.6)
139 2 SPI_RW(0x00); //Shift out zeros to release SDO
140 2 for(j=0;j<4;j++)
141 2 temp=SPI_RW(0x00);
142 2 _nop_();
143 2 _nop_();
144 2 CS5532_CS=1;
145 2 _nop_();
146 2 _nop_();
147 2 CS5532_CS=0;
148 2 }
149 1 for(i=0;i<5;i++)
150 1 {
151 2 while(RDYB); //Wait for SDO to drop(P1.6)
152 2 SPI_RW(0x00); //Shift out zeros to clear SDO
153 2 for(j=0;j<3;j++)
154 2 RxdByte[3*i+j]=SPI_RW(0x00);
155 2 SPI_RW(0x00);
156 2 _nop_();
157 2 _nop_();
158 2 CS5532_CS=1;
159 2 _nop_();
160 2 _nop_();
161 2 CS5532_CS=0;
162 2 }
163 1 while(RDYB); //Wait for SDO to drop(P1.6)
164 1 SPI_RW(0xff); //Shift out ones to stop continuous convert
165 1 for(j=0;j<4;j++)
166 1 temp=SPI_RW(0x00);
167 1 _nop_();
168 1 _nop_();
169 1 CS5532_CS=1; //Raise chip select
170 1 _nop_();
171 1 _nop_();
172 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 436 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 5
PDATA SIZE = ---- ----
C51 COMPILER V7.50 CS5532 03/16/2006 18:52:50 PAGE 4
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -