AN1305 An Evaluation System for Direct Interface of the MPX5100 Pressure Sensor with a Microprocessor

Freescale Semiconductor
Application Note
AN1305
Rev 2, 05/2005
An Evaluation System for Direct Interface
of the MPX5100 Pressure Sensor with a
Microprocessor
by: Bill Lucas
Discrete Applications Engineering
INTRODUCTION
Interfacing pressure sensors to analog-to-digital converters
or microprocessors with on-chip A/D converters has been a
challenge that most engineers do not enjoy accepting. Recent
design advances in pressure sensing technology have
allowed the engineer to directly interface a pressure sensor to
an A/D converter with no additional active components. This
has been made possible by integrating a temperature
compensated pressure sensor element and active linear
circuitry on the same die. A description of an evaluation board
that shows the ease of interfacing a signal conditioned
pressure sensor to an A/D converter is presented here.
Figure 1. DEVB-114 MPX5100 Evaluation Module
(Board No Longer Available)
© Freescale Semiconductor, Inc., 2005. All rights reserved.
PURPOSE
applied to the sensor is empirically computed each time power
is applied to the system and stored in RAM. The sensitivity of
the MPX5100 is repeatable from unit to unit. There is a facility
for a small “rubbering” of the slope constant built into the
program. It is accomplished with jumpers J1 and J2, and is
explained in the Operation section. The board contents are
further described in the schematic, silk screen plot, and parts
list that appear in Figure 2, Figure 3, and Table 1.
This evaluation system shown in Figure 1 demonstrates the
ease of operation and interfacing of the Freescale
Semiconductor, Inc. MPX5100 series pressure sensors with
on-chip temperature compensation, calibration and
amplification. The board may be used to evaluate the sensor's
suitability for a specific application.
DESCRIPTION
BASIC CIRCUIT
The DEVB-114 evaluation board is constructed on a small
printed circuit board. It is powered from a single +5 Vdc
regulated power supply. The system will display the pressure
applied to the MPX5100 sensor in pounds per square inch.
The range is 0 PSI through 15 PSI, resolved to 0.1 PSI. No
potentiometers are used in the system to adjust the span and
offset. The sensor's zero offset voltage with no pressure
The evaluation board consists of three basic subsystems:
an MPX5100GP pressure sensor, a four digit liquid crystal
display (only three digits and a decimal are used) and a
programmed microprocessor with the necessary external
circuitry to support the operation of the microprocessor.
LCD
LIQUID CRYSTAL DISPLAY
IEE PART NUMBER LCD5657 OR EQUAL.
BP
28 37 36 5
6
7 34 35
8
31 32 9
49
0
10
11 29 30
12
26 27 13
47 48 42 43 44 45 46
2 1 7
6
5 4 3
15 24 25
16
37 38 32 33 34 35 36
2 1 7 6
5 4 3
31
0
PORT C
14
PORT B
22 23 17
18
19 20 21 1–4, 33
39, 38, 40
29 30 24 25 26 27 28
2 1 7
6
5 4 3
+5
PORT A
R5
52
U1
TD0
VRH
8
~4.85 V
MC68HC705B5FN
50
R6
RDI
44 V
SS
VRL
OSC1
OSC2
PD5
16
17
5
4 MHz
Y1
PD6 PD7
4
3
10K
R3
+5
J3
GND
C1
R2
10 MEG
+
C2
100 µF
.1
RESET
19
18
22 pF
C4
J1
4.7K
R1
10K
R4
22 pF
C3
IRQ
J2
+5
PD4
PD3 PD1 VPP6 TCAP1
VDD PD2 PD0
D/A TCAP2
9 10 11 12 13 14 15
RESET
+5
21 22 23
15 OHM
1%
7
453 OHM
1%
~.302 V
R7
30.1 OHM
1%
U2
IN 34064P–
5
+5
+5
VCC
OUT
XDCR1
MPX5100
GND
Figure 2. DEVB-114 System Schematic
AN1305
2
Sensors
Freescale Semiconductor
Table 1. DEVB-114 Parts List
Designators
C1
Quant.
1
Description
Rating
100 µF Electrolytic Capacitor
Manufacturer
25 Vdc
Sprague
Part Number
513D107M025BB4
C2
1
0.1 µF Ceramic Capacitor
50 Vdc
Sprague
1C105Z5U104M050B
C3, C4
2
22 pF Ceramic Capacitor
100 Vdc
Mepco/Centralab
CN15A220K
J1, J2
1
Dual Row Straight .025 Pins
Arranged On .1″ Grid
Molex
10-89-1043
LCD
1
Liquid Crystal Display
AMPEREX
LTD226R-12
R1
1
4.7 k Ohm Resistor
R2
1
10 Meg Ohm Resistor
R3, R4
2
10 k Ohm Resistor
R5
1
15 Ohm 1% 1/4 W Resistor
R6
1
453 Ohm 1% 1/4 W Resistor
R7
1
30.1 Ohm 1% 1/4 W Resistor
XDCR1
1
Pressure Sensor
Freescale
MPX5100GP
U1
1
Microprocessor
Freescale
Freescale
MC68HC705B5FN or
XC68HC705B5FN
Freescale
MC34064P-5
ECS
ECS-40-S-4
U2
1
Under Voltage Detector
Y1
1
Crystal (Low Profile)
4.0 MHz
No Designator
1
52 Pin PLCC Socket
AMP
821-575-1
No Designator
2
Jumpers For J1 and J2
Molex
15-29-1025
No Designator
1
Bare Printed Circuit Board
Notes: All resistors are 1/4 W resistors with a tolerance of 5% unless otherwise noted.
All capacitors are 100 volt, ceramic capacitors with a tolerance of 10% unless otherwise noted.
LCD1
U1
J1
J2
R1
R3
R4
R5
R6
R7
C2 C3
C1
+
GND
J3
+5
Y1
R2
1
C4
U2
VCC TP1
XDRC OUT TP2
GND TP3
XDRC1
DEVB-114
REV. 0
Figure 3. Silk Screen
AN1305
Sensors
Freescale Semiconductor
3
Theory of Operation
Referring to the schematic, Figure 2, the MPX5100
pressure sensor is connected to PORT D bit 5 of the
microprocessor. This port is an input to the on-chip 8 bit
analog to digital converter. The pressure sensor provides a
signal output to the microprocessor of approximately 0.5 Vdc
at 0 psi to 4.5 Vdc at 15 psi of applied pressure as shown in
Figure 4. The input range of the A to D converter is set at
approximately 0.3 Vdc to 4.85 Vdc. This compresses the
range of the A to D converter around the output range of the
sensor to maximize the A to D converter resolution; 0 to 255
counts is the range of the A to D converter. VRH and VRL are
the reference voltage inputs to the A to D converter. The
resolution is defined by the following:
Analog-to-digital converter count =
[(Vxdcr -VRL)/(VRH -VRL)] • 255
The count at 0 psi = [(.5-.302)/(4.85-.302)] • 255 ≈ 11
The count at 15 psi = [(4.5-.302)/(4.85-.302)] • 255 ≈ 235
Therefore the resolution = count @ 15 psi - count @ 0 psi or
the resolution is (235 - 11) = 224 counts. This translates to a
system that will resolve to 0.1 psi.
VS = 5.0 Vdc
TA = 25°C
MPX5100
TYP
MAX
MIN
0.5
0
kPa 0
PSI
TYP SPAN
OUTPUT (Vdc)
4.5
TYP OFFSET
25
3.62
50
7.25
75
10.87
100
13.4
Figure 4. MPX5100 Output versus Pressure Input
The voltage divider consisting of R5 through R7 is
connected to the +5 volts powering the system. The output of
the pressure sensor is ratiometric to the voltage applied to it.
The pressure sensor and the voltage divider are connected to
a common supply; this yields a system that is ratiometric. By
nature of this ratiometric system, variations in the voltage of
the power supplied to the system will have no effect on the
system accuracy.
The liquid crystal display is directly driven from I/O ports A,
B, and C on the microprocessor. The operation of a liquid
crystal display requires that the data and backplane pins must
be driven by an alternating signal. This function is provided by
a software routine that toggles the data and backplane at
approximately a 30 Hz rate.
The microprocessor section of the system requires certain
support hardware to allow it to function. The MC34064P-5
(U2) provides an under voltage sense function which is used
to reset the microprocessor at system power-up. The 4 MHz
crystal (Y1) provides the external portion of the oscillator
function for clocking the microprocessor and provides a stable
base for time based functions. Jumpers J1 and J2 are
examined by the software and are used to “rubber” the slope
constant.
OPERATION
The system must be connected to a 5 Vdc regulated power
supply. Note the polarity marked on the power terminal J3.
Jumpers J1 and J2 must either both be installed or both be
removed for the normal slope constant to be used. The
pressure port on the MPX5100 sensor must be left open to
atmosphere anytime the board is powered-up. As previously
stated, the sensor’s voltage offset with zero pressure applied
is computed at power-up.
You will need to apply power to the system. The LCD will
display CAL for approximately 5 seconds. After that time, the
LCD will then start displaying pressure.
To improve upon the accuracy of the system, you can
change the constant used by the program that constitutes the
span of the sensor. You will need an accurate test gauge to
measure the pressure applied to the sensor. Anytime after the
display has completed the zero calculation (after CAL is no
longer displayed), apply 15.0 PSI to the sensor. Make sure
that jumpers J1 and J2 are either both installed or both
removed. Referring to Table 2, you can increase the displayed
value by installing J1 and removing J2. Conversely, you can
decrease the displayed value by installing J2 and removing
J1.
Table 2. J1/J2 Installation
J1
J2
Action
IN
IN
Use Normal Span Constant
OUT
OUT
Use Normal Span Constant
OUT
IN
Decrease Span Constant Approximately 1.5%
IN
OUT
Increase Span Constant Approximately 1.5%
SOFTWARE
The source code, compiler listing, and S-record output for
the software used in this system are available on the
Freescale Freeware Bulletin Board Service in the MCU
directory under the filename DEVB-114.ARC. To access the
bulletin board you must have a telephone line, a 300, 1200 or
2400 baud modem and a terminal or personal computer. The
modem must be compatible with the Bell 212A standard. Call
1-512-891-3733 to access the Bulletin Board Service.
The software for the system consists of several modules.
Their functions provide the capability for system calibration as
well as displaying the pressure input to the MPX5100
transducer.
Figure 5 is a flowchart for the program that controls the
system.
AN1305
4
Sensors
Freescale Semiconductor
Start
Initalize Display I/O Ports
Initalize Timer Registers
Allow Interrupts
Perform Auto Zero
Slope = 64
Timer
Interrupt
J1 Out?
Service Timer Registers
Setup Counter for Next Interrupt
Service Liquid Crystal Display
Return From Interrupt
YES
Slope = 63
NO
J2 Out?
YES
Slope = 65
NO
Accumulate 100 A/D Conversions
Compute Input Pressure
Convert to Decimal
Place in Result Output Buffer
Figure 5. DEVB-114 Software Flowchart
The compiler used in this project was provided by BYTE
CRAFT LTD. (519) 888-6911. A compiler listing of the program
is included at the end of this document. The following is a brief
explanation of the routines:
delay() Used to provide approximately a 20 ms loop.
read_a2d() Performs one hundred reads on the analog to
digital converter on multiplexer channel 5 and returns the
accumulation.
fixcompare() Services the internal timer for 30 ms timer
compare interrupts.
TIMERCMP() Alternates the data and backplane for the liquid
crystal display.
initio() Sets up the microcomputer’s I/O ports, timer, allows
processor interrupts, and calls adzero().
adzero() This routine is necessary at power-up time because
it delays the power supply and allows the transducer to
stabilize. It then calls ‘read_atod()’ and saves the returned
value as the sensors output voltage with zero pressure
applied.
cvt_bin_dec(unsigned long arg) This routine converts the
unsigned binary argument passed in ‘arg’ to a five digit
decimal number in an array called ‘digit’. It then uses the
decimal results for each digit as an index into a table that
converts the decimal number into a segment pattern for the
display. It is then output to the display.
display_psi() This routine is called from ‘main()’. The analog
to digital converter routine is called, the pressure is calculated,
and the pressure applied to the sensor is displayed. The loop
then repeats.
main() This is the main routine called from reset. It calls
‘initio()’ to set up the system’s I/O. ‘display_psi()’ is called to
compute and display the pressure applied to the sensor.
AN1305
Sensors
Freescale Semiconductor
5
SOFTWARE SOURCE/ASSEMBLY PROGRAM CODE
#pragma option v ;
/*
rev 1.1 code rewritten to use the MC68HC705B5 instead of the
MC68HC805B6. WLL 6/17/91
THE FOLLOWING 'C' SOURCE CODE IS WRITTEN FOR THE DEVB-114 DEMONSTRATION
BOARD. IT WAS COMPILED WITH A COMPILER COURTESY OF:
BYTE CRAFT LTD.
421 KING ST.
WATERLOO, ONTARIO
CANADA N2J 4E4
(519)888-6911
SOME SOURCE CODE CHANGES MAY BE NECESSARY FOR COMPILATION WITH OTHER
COMPILERS.
BILL LUCAS 8/5/90
FREESCALE, SPS
*/
0800 1700
0050 0096
#pragma memory ROMPROG [5888]
#pragma memory RAMPAGE0 [150]
1FFE
1FFC
1FFA
1FF8
1FF6
1FF4
1FF2
/*
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
@ 0x0800 ;
@ 0x0050 ;
Vector assignments
*/
vector __RESET
@ 0x1ffe
vector __SWI
@ 0x1ffc
vector IRQ
@ 0x1ffa
vector TIMERCAP @ 0x1ff8
vector TIMERCMP @ 0x1ff6
vector TIMEROV
@ 0x1ff4
vector SCI
@ 0x1ff2
;
;
;
;
;
;
;
#pragma has STOP ;
#pragma has WAIT ;
#pragma has MUL ;
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
000B
000C
000D
000E
000F
0010
/*
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
Register assignments for the 68HC705B5 microcontroller
*/
portrw porta
@ 0x00; /*
portrw portb
@ 0x01; /*
portrw portc
@ 0x02; /*
portrw portd
@ 0x03; /* in ,- ,SS ,SCK ,MOSI,MISO,TxD,RxD
portrw ddra
@ 0x04; /* Data direction, Port A
portrw ddrb
@ 0x05; /* Data direction, Port B
portrw ddrc
@ 0x06; /* Data direction, Port C (all output)
portrw eeclk
@ 0x07; /* eeprom/eclk cntl */
portrw addata @ 0x08; /* a/d data register */
portrw adstat @ 0x09; /* a/d stat/control */
portrw plma
@ 0x0a; /* pulse length modulation a */
portrw plmb
@ 0x0b; /* pulse length modulation b */
portrw misc
@ 0x0c; /* miscellaneous register */
portrw scibaud @ 0x0d; /* sci baud rate register */
portrw scicntl1 @ 0x0e; /* sci control 1 */
portrw scicntl2 @ 0x0f; /* sci control 2 */
portrw scistat @ 0x10; /* sci status reg */
*/
*/
*/
*/
*/
*/
*/
AN1305
6
Sensors
Freescale Semiconductor
0011
0012
0013
0014
0015
0016
0017
0018
0019
001A
001B
001C
001D
001E
001F
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
portrw
scidata
tcr
tsr
icaphi1
icaplo1
ocmphi1
ocmplo1
tcnthi
tcntlo
acnthi
acntlo
icaphi2
icaplo2
ocmphi2
ocmplo2
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
0x11;
0x12;
0x13;
0x14;
0x15;
0x16;
0x17;
0x18;
0x19;
0x1A;
0x1B;
0x1c;
0x1d;
0x1e;
0x1f;
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
SCI Data */
ICIE,OCIE,TOIE,0;0,0,IEGE,OLVL
*/
ICF,OCF,TOF,0; 0,0,0,0
*/
Input Capture Reg (Hi-0x14, Lo-0x15) */
Input Capture Reg (Hi-0x14, Lo-0x15) */
Output Compare Reg (Hi-0x16, Lo-0x17)*/
Output Compare Reg (Hi-0x16, Lo-0x17)*/
Timer Count Reg (Hi-0x18, Lo-0x19)
*/
Timer Count Reg (Hi-0x18, Lo-0x19)
*/
Alternate Count Reg (Hi-$1A, Lo-$1B) */
Alternate Count Reg (Hi-$1A, Lo-$1B) */
Input Capture Reg (Hi-0x1c, Lo-0x1d) */
Input Capture Reg (Hi-0x1c, Lo-0x1d) */
Output Compare Reg (Hi-0x1e, Lo-0x1f)*/
Output Compare Reg (Hi-0x1e, Lo-0x1f)*/
/* put constants and variables here...they must be global */
1EFE 74
/***********************************************************************/
#pragma mor @ 0x1EFE = 0x74;/*this disables the watchdog counter and does not
add pull-down resistors on ports B and C */
0800 FC 30 DA 7A 36 6E E6 38 FE const char lcdtab[]={0xfc,0x30,0xda,0x7a,0x36,0x6e,0xe6,0x38,0xfe,0x3e };
0809 3E
/* lcd pattern table 0
1
2
3
4
5
6
7
8
9
*/
080A 27 10 03 E8 00 64 00 0A
const long dectable[] = { 10000, 1000, 100, 10 };
0050 0005
unsigned int digit[5]; /* buffer to hold results from cvt_bin_dec functio*/
0000
registera ac;
/* processor's A register */
0055
long atodtemp;
/* temp to accumulate 100 a/d readings for smoothing */
0059
long slope;
/* multiplier for adc to engineering units conversion */
005B
int adcnt;
/* a/d converter loop counter */
005C
long xdcr_offset;
/* initial xdcr offset */
005E 0060
unsigned long i,j; /* counter for loops */
0062
int k;
/* misc variable */
struct bothbytes
{ int hi;
int lo;
};
union isboth
{ long l;
struct bothbytes b;
};
0063 0002
union isboth q;
/* used for timer set-up */
AN1305
Sensors
Freescale Semiconductor
7
/**************************************************************************/
/* code starts here */
/**************************************************************************/
/* these interrupts are not used...give them a graceful return if for
some reason one occurs */
1FFC
0812
1FFA
0813
1FF8
0814
1FF4
0815
1FF2
0816
08
80
08
80
08
80
08
80
08
80
12
__SWI(){}
RTI
13
IRQ(){}
RTI
14
TIMERCAP(){}
RTI
15
TIMEROV(){}
RTI
16
SCI(){}
RTI
/**************************************************************************/
0817
0818
081A
081C
081E
0820
0822
0824
0826
0828
082A
082C
082E
0830
0832
0834
0836
4F
3F
B7
B6
B7
B6
B7
B6
A0
B6
A2
24
3C
26
3C
20
81
void delay(void) /* just hang around for a while */
{
for (i=0; i<20000; ++i);
57
58
57
5E
58
5F
5F
20
5E
4E
08
5F
02
5E
EE
CLRA
CLR
$57
STA
$58
LDA
$57
STA
$5E
LDA
$58
STA
$5F
LDA
$5F
SUB
#$20
LDA
$5E
SBC
#$4E
BCC
$0836
INC
$5F
BNE
$0834
INC
$5E
BRA
$0824
RTS
}
/**************************************************************************/
read_a2d(void)
{
/* read the a/d converter on channel 5 and accumulate the result
in atodtemp */
0837
0839
083B
083C
083E
0840
0842
0844
3F
3F
4F
B7
B6
A8
A1
24
56
55
5B
5B
80
E4
21
CLR
CLR
CLRA
STA
LDA
EOR
CMP
BCC
$56
$55
atodtemp=0;
/* zero for accumulation */
for ( adcnt = 0 ; adcnt<100; ++adcnt) /* do 100 a/d conversions */
$5B
$5B
#$80
#$E4
$0867
AN1305
8
Sensors
Freescale Semiconductor
{
0846
0848
084A
084D
084F
0851
0853
0855
0857
0859
085B
085D
085F
0861
A6
B7
0F
B6
3F
B7
BB
B7
B6
B9
B7
B7
B6
B7
25
09
09 FD
08
57
58
56
58
57
55
57
55
58
56
LDA
#$25
STA
$09
BRCLR 7,$09,$084A
LDA
$08
CLR
$57
STA
$58
ADD
$56
STA
$58
LDA
$57
ADC
$55
STA
$57
STA
$55
LDA
$58
STA
$56
0863
0865
0867
0869
086B
086D
086F
0871
0873
0875
0878
087B
087D
087F
3C
20
B6
B7
B6
B7
3F
A6
B7
CD
CD
BF
B7
81
5B
D7
56
58
55
57
66
64
67
0A 5E
0A 8F
55
56
INC
BRA
LDA
STA
LDA
STA
CLR
LDA
STA
JSR
JSR
STX
STA
RTS
adstat = 0x25;
/* convert on channel 5 */
while (!(adstat & 0x80)); /* wait for a/d to complete */
atodtemp = addata + atodtemp;
}
$5B
$083E
$56
$58
$55
$57
$66
#$64
$67
$0A5E
$0A8F
$55
$56
atodtemp = atodtemp/100;
return atodtemp;
}
0880
0882
0884
0886
0888
088A
088C
088E
0890
0892
0894
0896
0898
089A
B6
B7
B6
B7
AB
B7
B6
A9
B7
B7
B6
B6
B7
81
18
63
19
64
4C
64
63
1D
63
16
13
64
17
LDA
STA
LDA
STA
ADD
STA
LDA
ADC
STA
STA
LDA
LDA
STA
RTS
/**************************************************************************/
void fixcompare (void) /* sets-up the timer compare for the next interrup */
{
$18
q.b.hi =tcnthi;
$63
$19
q.b.lo = tcntlo;
$64
#$4C
q.l +=7500; /* ((4mhz xtal/2)/4) = counter period = 2us.*7500 = 15ms.*/
$64
$63
#$1D
$63
$16
ocmphi1 = q.b.hi;
$13
ac=tsr;
$64
ocmplo1 = q.b.lo;
$17
}
1FF6 08 9B
/*************************************************************************/
void TIMERCMP (void)
/* timer service module */
{
AN1305
Sensors
Freescale Semiconductor
9
089B
089D
089F
08A1
08A3
33
33
33
AD
80
02
01
00
DD
COM
COM
COM
BSR
RTI
$02
$01
$00
$0880
portc =~ portc;
portb =~ portb;
porta =~ porta;
fixcompare();
/* service the lcd */
}
/************************************************************************/
void adzero(void)
/* called by initio() to save initial xdcr's zero
pressure offset voltage output */
{
08A4
08A5
08A7
08A9
08AB
08AD
08AF
08B1
08B3
08B5
08B7
08B9
4F
3F
B7
B6
B7
B6
B7
B6
A0
B6
A2
24
57
58
57
60
58
61
61
14
60
00
0B
CLRA
CLR
STA
LDA
STA
LDA
STA
LDA
SUB
LDA
SBC
BCC
for ( j=0; j<20; ++j)
/* give the sensor time to "warm-up" and the
$57
$58
$57
$60
$58
$61
$61
#$14
$60
#$00
$08C6
power supply time to settle down */
{
08BB CD 08 17
JSR
$0817
delay();
}
08BE
08C0
08C2
08C4
08C6
08C9
08CB
08CD
08CE
08D0
08D2
08D4
08D6
08D8
08DA
08DC
08DE
08E0
08E2
08E4
08E6
08E8
3C
26
3C
20
CD
3F
B7
81
A6
B7
3F
3F
3F
A6
B7
B7
B7
B6
3F
3F
B6
AD
61
02
60
EB
08 37
5C
5D
20
09
02
01
00
FF
06
05
04
13
1E
16
1F
96
INC
BNE
INC
BRA
JSR
CLR
STA
RTS
$61
$08C4
$60
$08B1
$0837
$5C
$5D
}
LDA
STA
CLR
CLR
CLR
LDA
STA
STA
STA
LDA
CLR
CLR
LDA
BSR
/**************************************************************************/
void initio (void)
/* setup the I/O */
{
#$20
adstat = 0x20; /* power-up the A/D */
$09
$02
porta = portb = portc = 0;
$01
$00
#$FF
ddra = ddrb = ddrc = 0xff;
$06
$05
$04
$13
ac=tsr; /* dummy read */
$1E
ocmphi1 = ocmphi2 = 0;
$16
$1F
ac = ocmplo2; /* clear out output compare 2 if it happens to be set */
$0880
fixcompare(); /* set-up for the first timer interrupt */
xdcr_offset =
read_a2d();
AN1305
10
Sensors
Freescale Semiconductor
08EA A6 40
08EC B7 12
08EE 9A
LDA
STA
CLI
#$40
$12
08EF
08F1
08F3
08F5
08F7
08F9
08FB
08FD
LDA
STA
LDA
STA
LDA
STA
BSR
RTS
#$CC
$02
#$BE
$01
#$C4
$00
$08A4
A6
B7
A6
B7
A6
B7
AD
81
CC
02
BE
01
C4
00
A7
tcr = 0x40;
CLI; /* let the interrupts begin !
/* write CAL to the display */
portc = 0xcc; /* C */
*/
portb = 0xbe; /* A */
porta = 0xc4; /* L */
adzero();
}
/**************************************************************************/
void cvt_bin_dec(unsigned long arg)
/* First converts the argument to a five digit decimal value. The msd is in
the lowest address. Then leading zero suppresses the value and writes it to
the display ports.
The argument value range is 0..65535 decimal. */
0069
08FE
0900
006B
006C
0902
0903
0905
0907
0909
{
BF 69
B7 6A
4F
B7
B6
A1
24
6B
6B
05
07
STX
STA
CLRA
STA
LDA
CMP
BCC
$69
$6A
char i;
unsigned long l;
for ( i=0; i < 5; ++i )
$6B
$6B
#$05
$0912
{
090B 97
090C 6F 50
TAX
CLR
090E
0910
0912
0913
0915
0917
0919
3C
20
4F
B7
B6
A1
24
6B
6B
04
70
INC
BRA
CLRA
STA
LDA
CMP
BCC
091B
091C
091D
0920
0922
0924
0927
0929
97
58
D6
B1
26
D6
B1
27
08 0B
6A
07
08 0A
69
5C
TAX
LSLX
LDA
CMP
BNE
LDA
CMP
BEQ
092B BE 6B
092D 58
092E D6 08 0A
LDX
LSLX
LDA
digit[i] = 0x0;
/* put blanks in all digit positions */
$50,X
}
6B
F3
$6B
$0905
for ( i=0; i < 4; ++i )
$6B
$6B
#$04
$098B
{
if ( arg
>= dectable [i] )
$080B,X
$6A
$092B
$080A,X
$69
$0987
{
$6B
l = dectable[i];
$080A,X
AN1305
Sensors
Freescale Semiconductor
11
0933
0936
0938
093A
093C
093E
0940
0942
0944
0946
0948
094B
094E
0950
0952
0954
0956
0958
095A
095C
095E
0960
0962
0964
0966
0969
096B
096D
096F
0971
0973
0975
0977
0979
097B
097D
097F
0981
0983
0985
D6
B7
B6
B7
B6
B7
B6
B7
B6
B7
CD
CD
BF
B7
BE
E7
BE
E6
3F
B7
B6
B7
B6
B7
CD
BF
B7
33
30
26
3C
B6
BB
B7
B6
B9
B7
B7
B6
B7
08
6D
6A
58
69
57
6C
66
6D
67
0A
0A
57
58
6B
50
6B
50
57
58
6C
66
6D
67
0A
57
58
57
58
02
57
58
6A
58
57
69
57
69
58
6A
0B
5E
8F
3F
LDA
STA
LDA
STA
LDA
STA
LDA
STA
LDA
STA
JSR
JSR
STX
STA
LDX
STA
LDX
LDA
CLR
STA
LDA
STA
LDA
STA
JSR
STX
STA
COM
NEG
BNE
INC
LDA
ADD
STA
LDA
ADC
STA
STA
LDA
STA
$080B,X
$6D
$6A
$58
$69
$57
$6C
$66
$6D
$67
$0A5E
$0A8F
$57
$58
$6B
$50,X
$6B
$50,X
$57
$58
$6C
$66
$6D
$67
$0A3F
$57
$58
$57
$58
$0975
$57
$58
$6A
$58
$57
$69
$57
$69
$58
$6A
digit[i] = arg / l;
arg = arg-(digit[i] * l);
}
}
0987
0989
098B
098D
098F
0991
0993
0995
0997
3C
20
B6
B7
B6
B7
BE
B6
E7
0999 9B
6B
8A
6A
58
69
57
6B
58
50
INC
BRA
LDA
STA
LDA
STA
LDX
LDA
STA
SEI
$6B
$0915
$6A
$58
$69
$57
$6B
$58
$50,X
digit[i] = arg;
/* now zero suppress and send the lcd pattern to the display */
SEI;
AN1305
12
Sensors
Freescale Semiconductor
099A
099C
099E
09A0
09A2
09A4
09A7
09A9
09AB
09AD
09AF
09B1
09B3
09B5
09B7
09BA
09BC
09BE
09C1
09C2
09C4
09C5
09C8
3D
26
3F
20
BE
D6
B7
3D
26
3D
26
3F
20
BE
D6
B7
BE
D6
4C
B7
9A
CD
81
50
04
02
07
50
08 00
02
50
08
51
04
01
07
51
08 00
01
52
08 00
00
08 17
TST
BNE
CLR
BRA
LDX
LDA
STA
TST
BNE
TST
BNE
CLR
BRA
LDX
LDA
STA
LDX
LDA
INCA
STA
CLI
JSR
RTS
$50
$09A2
$02
$09A9
$50
$0800,X
$02
$50
$09B5
$51
$09B5
$01
$09BC
$51
$0800,X
$01
$52
$0800,X
if ( digit[0] == 0 )
/* leading zero suppression */
portc = 0;
else
portc = ( lcdtab[digit[0]] );
/* 100's digit */
if ( digit[0] == 0 && digit[1] == 0 )
portb=0;
else
portb = ( lcdtab[digit[1]] );
/* 10's digit */
porta = ( lcdtab[digit[2]]+1 ); /* 1's digit + decimal point */
$00
CLI;
$0817
delay();
}
/****************************************************************/
09C9
09CB
09CD
09CF
09D1
09D3
3F
A6
B7
B6
A4
B7
59
40
5A
03
C0
62
CLR
LDA
STA
LDA
AND
STA
$59
#$40
$5A
$03
#$C0
$62
09D5
09D7
09D9
09DB
09DD
09DF
A1
26
3F
A6
B7
B6
80
06
59
41
5A
62
CMP
BNE
CLR
LDA
STA
LDA
#$80
$09DF
$59
#$41
$5A
$62
void display_psi(void)
/* At power-up it is assumed that the pressure port of the sensor
is open to atmosphere. The code in initio() delays for the
sensor and power to stabilize. One hundred A/D conversions are
averaged and divided by 100. The result is called xdcr_offset.
This routine calls the A/D routine which performs one hundred
conversions, divides the result by 100 and returns the value.
If the value returned is less than or equal to the xdcr_offset,
the value of xdcr_offset is substituted. If the value returned
is greater than xdcr_offset, xdcr_offset is subtracted from the
returned value. That result is multiplied by a constant to yield
pressure in PSI * 10 to yield a "decimal point".
*/
{
while(1)
{
slope = 64;
k = portd & 0xc0;
if ( k == 0x80 )
/* this lets us "rubber" the slope to closer fit
the slope of the sensor */
/* J2 removed, J1 installed */
slope = 65;
if ( k == 0x40 ) /* J1 removed, J2 installed */
AN1305
Sensors
Freescale Semiconductor
13
09E1
09E3
09E5
09E7
09E9
A1
26
3F
A6
B7
40
06
59
3F
5A
CMP
BNE
CLR
LDA
STA
#$40
$09EB
$59
#$3F
$5A
09EB
09EE
09F0
09F2
09F4
09F6
09F8
09FA
09FC
09FE
0A00
0A02
0A04
0A06
0A08
0A0A
0A0C
0A0E
0A10
0A12
0A14
0A16
0A18
0A1A
0A1C
0A1E
0A20
0A22
0A24
0A26
0A28
0A2A
0A2D
0A2F
0A31
0A34
0A36
CD
3F
B7
B0
B7
B6
A8
B7
B6
A8
B2
BA
22
B6
B7
B6
B7
B6
B0
B7
B6
B2
B7
B6
B7
B6
B7
B6
B7
B6
B7
CD
BF
B7
CD
20
81
08 37
55
56
5D
58
5C
80
57
55
80
57
58
08
5C
55
5D
56
56
5D
56
55
5C
55
56
58
55
57
59
66
5A
67
0A 3F
55
56
08 FE
93
JSR
CLR
STA
SUB
STA
LDA
EOR
STA
LDA
EOR
SBC
ORA
BHI
LDA
STA
LDA
STA
LDA
SUB
STA
LDA
SBC
STA
LDA
STA
LDA
STA
LDA
STA
LDA
STA
JSR
STX
STA
JSR
BRA
RTS
$0837
$55
$56
$5D
$58
$5C
#$80
$57
$55
#$80
$57
$58
$0A0E
$5C
$55
$5D
$56
$56
$5D
$56
$55
$5C
$55
$56
$58
$55
$57
$59
$66
$5A
$67
$0A3F
$55
$56
$08FE
$09C9
slope = 63;
/* else both jumpers are removed or installed... don't change the slope */
atodtemp = read_a2d(); /* atodtemp = raw a/d ( 0..255 ) */
if ( atodtemp <= xdcr_offset )
atodtemp = xdcr_offset;
atodtemp -=
xdcr_offset; /* remove the offset */
atodtemp *= slope; /* convert to psi */
cvt_bin_dec( atodtemp ); /* convert to decimal and display */
}
}
/************************************************************************/
0A37
0A3A
0A3C
0A3E
CD 08 CE
AD 8D
20 FE
81
0A3F BE 58
0A41 B6 67
JSR
BSR
BRA
RTS
$08CE
$09C9
$0A3C
LDX
LDA
$58
$67
main()
{
initio(); /* set-up the processor's i/o */
display_psi();
while(1);
/* should never get here */
}
AN1305
14
Sensors
Freescale Semiconductor
0A43
0A44
0A46
0A48
0A4A
0A4C
0A4D
0A4F
0A51
0A53
0A55
0A56
0A58
0A5A
0A5B
0A5D
42
B7
BF
BE
B6
42
BB
B7
BE
B6
42
BB
B7
97
B6
81
0A5E
0A60
0A61
0A63
0A65
0A66
0A68
0A6A
0A6C
0A6E
0A70
0A72
0A74
0A76
0A78
0A7A
0A7C
0A7E
0A80
0A82
0A84
0A86
0A88
0A89
0A8A
0A8C
0A8E
0A8F
0A90
0A91
0A93
0A94
1FFE
3F
5F
3F
3F
5C
38
39
39
39
B6
B0
B7
B6
B2
B7
24
B6
BB
B7
B6
B9
B7
99
59
39
24
81
53
9F
BE
53
81
0A
70
71
57
67
71
71
58
66
71
71
70
70
6E
6F
58
57
6E
6F
6E
67
6E
6F
66
6F
0D
67
6E
6E
66
6F
6F
70
D8
70
MUL
STA
STX
LDX
LDA
MUL
ADD
STA
LDX
LDA
MUL
ADD
STA
TAX
LDA
RTS
CLR
CLRX
CLR
CLR
INCX
LSL
ROL
ROL
ROL
LDA
SUB
STA
LDA
SBC
STA
BCC
LDA
ADD
STA
LDA
ADC
STA
SEC
ROLX
ROL
BCC
RTS
COMX
TXA
LDX
COMX
RTS
$70
$71
$57
$67
$71
$71
$58
$66
$71
$71
$70
$70
$6E
$6F
$58
$57
$6E
$6F
$6E
$67
$6E
$6F
$66
$6F
$0A89
$67
$6E
$6E
$66
$6F
$6F
$70
$0A66
$70
37
AN1305
Sensors
Freescale Semiconductor
15
SYMBOL TABLE
LABEL
VALUE
IRQ
TIMEROV
__MUL16x16
__STOP
acnthi
adstat
b
ddrb
digit
hi
icaplo1
j
lo
ocmphi2
plmb
portd
scicntl1
slope
tsr
0813
0815
0A3F
0000
001A
0009
0000
0005
0050
0000
0015
0060
0001
001E
000B
0003
000E
0059
0013
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LABEL
VALUE
SCI
__LDIV
__RDIV
__SWI
acntlo
adzero
bothbytes
ddrc
display_psi
i
icaplo2
k
main
ocmplo1
porta
q
scicntl2
tcnthi
xdcr_offset
0816
0A5E
0A8F
0812
001B
08A4
0002
0006
09C9
005E
001D
0062
0A37
0017
0000
0063
000F
0018
005C
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LABEL
VALUE
TIMERCAP
__LongIX
__RESET
__WAIT
adcnt
arg
cvt_bin_dec
dectable
eeclk
icaphi1
initio
l
misc
ocmplo2
portb
read_a2d
scidata
tcntlo
0814
0066
1FFE
0000
005B
0069
08FE
080A
0007
0014
08CE
0000
000C
001F
0001
0837
0011
0019
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LABEL
VALUE
TIMERCMP
__MUL
__STARTUP
__longAC
addata
atodtemp
ddra
delay
fixcompare
icaphi2
isboth
lcdtab
ocmphi1
plma
portc
scibaud
scistat
tcr
089B
0000
0000
0057
0008
0055
0004
0817
0880
001C
0002
0800
0016
000A
0002
000D
0010
0012
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
0100
0140
0180
01C0
:
:
:
:
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-----------------------------------------------------------X-
0800
0840
0880
08C0
:
:
:
:
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
0900
0940
0980
09C0
:
:
:
:
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
0A00
0A40
0A80
0AC0
:
:
:
:
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
----------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXX--------------------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
-------------------------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
-------------------------------
1F00
1F40
1F80
1FC0
:
:
:
:
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-----------------------------------------------XXXXXXXXXXXXXX
All other memory blocks unused.
Errors
:
0
Warnings
:
0
AN1305
16
Sensors
Freescale Semiconductor
NOTES
AN1305
Sensors
Freescale Semiconductor
17
NOTES
AN1305
18
Sensors
Freescale Semiconductor
NOTES
AN1305
Sensors
Freescale Semiconductor
19
How to Reach Us:
Home Page:
www.freescale.com
E-mail:
[email protected]
USA/Europe or Locations Not Listed:
Freescale Semiconductor
Technical Information Center, CH370
1300 N. Alma School Road
Chandler, Arizona 85224
+1-800-521-6274 or +1-480-768-2130
[email protected]
Europe, Middle East, and Africa:
Freescale Halbleiter Deutschland GmbH
Technical Information Center
Schatzbogen 7
81829 Muenchen, Germany
+44 1296 380 456 (English)
+46 8 52200080 (English)
+49 89 92103 559 (German)
+33 1 69 35 48 48 (French)
[email protected]
Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064
Japan
0120 191014 or +81 3 5437 9125
[email protected]
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center
2 Dai King Street
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong
+800 2666 8080
[email protected]
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center
P.O. Box 5405
Denver, Colorado 80217
1-800-441-2447 or 303-675-2140
Fax: 303-675-2150
[email protected]
AN1305
Rev. 2
05/2005
Information in this document is provided solely to enable system and software
implementers to use Freescale Semiconductor products. There are no express or
implied copyright licenses granted hereunder to design or fabricate any integrated
circuits or integrated circuits based on the information in this document.
Freescale Semiconductor reserves the right to make changes without further notice to
any products herein. Freescale Semiconductor makes no warranty, representation or
guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor assume any liability arising out of the application or use of any
product or circuit, and specifically disclaims any and all liability, including without
limitation consequential or incidental damages. “Typical” parameters that may be
provided in Freescale Semiconductor data sheets and/or specifications can and do vary
in different applications and actual performance may vary over time. All operating
parameters, including “Typicals”, must be validated for each customer application by
customer’s technical experts. Freescale Semiconductor does not convey any license
under its patent rights nor the rights of others. Freescale Semiconductor products are
not designed, intended, or authorized for use as components in systems intended for
surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
could create a situation where personal injury or death may occur. Should Buyer
purchase or use Freescale Semiconductor products for any such unintended or
unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
its officers, employees, subsidiaries, affiliates, and distributors harmless against all
claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
directly or indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
All other product or service names are the property of their respective owners.
© Freescale Semiconductor, Inc. 2005. All rights reserved.