AN1950
Sensors
16 Freescale Semiconductor
lsr DC
ror DB
ror DA ;divide DC:DB:DA by 2
lda NA
add DA
sta NA
lda NB
adc DB
sta NB
lda NC
adc DC
sta NC ;and add into NC:NB:NA
lsla
bcs nornd ;if carry=1 then remainder<1/2 of dividend
lda RA
add #$01
sta RA
lda RB
adc #$00
sta RB ;otherwise add 1 to result
nornd: rts
;__________________________________________________________
;__________________________________________________________
UNITS: brclr 2,porta,UNITS ;let go of ENT first
lda #$01 ;===UNITS=== Allows user to select units: inches or cm
jsr lcdcmdo ;clear screen
ldhx #msg03
jsr lcdstro ;Unit Choice menu
jsr del100ms
clr RA ;menu choice=0 to begin with
lda #$0D
jsr lcdcmdo ;blink cursor on menu choice
uluke: ldx RA ;get current menu choice
clrh
lda menupos,x ;and look up corresponding LCD address
jsr lcdcmdo ;reposition cursor
uwarm: brclr 1,porta,uPB1 ;check for SEL
brclr 2,porta,uPB2 ;or for ENT
bclr 4,porta ;otherwise
bset 5,porta ;turn on "SEL" LED
jsr del100ms ;delay
bset 4,porta ;toggle LEDs
bclr 5,porta ;"ENT" now on: means choice is SEL ***or*** ENT
jsr del100ms ;delay and repeat until SEL or ENT
bra uwarm
uPB1: inc RA ;***SEL*** toggles menu choices
lda RA
cmp #$02 ;menu choices are $00 and $01
bne uPB1ok
clr RA ;back to $00 when all others have been offered
uPB1ok: bclr 4,porta
bclr 5,porta ;LEDs off
jsr del100ms ;wait a little bit
brclr 1,porta,uPB1ok ;make sure they let go of SEL
bra uluke
AN1950
Sensors
Freescale Semiconductor 17
uPB2: bclr 4,porta ;***ENT*** confirms menu choice
bclr 5,porta ;LEDs off
lda RA ;get menu choice
bne SelIN
SelCM: ldhx #$A014 ;initialize default units to cm ($A0=cm, $3F=in)
sthx UnitType ;UnitType set to $A0; UnitDiv set to $14
ldhx #$039E
sthx UnitEmpt ;UnitEmpt set to $03; UnitFull set to $9E
lda #$01
jsr lcdcmdo ;clear LCD
ldhx #msg03a
jsr lcdstro ;and show choice selection to be cm
jsr del1s ;wait 1s
jmp LEVEL ;let's do LEVEL now...
SelIN: ldhx #$3F08 ;initialize default units to in ($A0=cm, $3F=in)
sthx UnitType ;UnitType set to $3F; UnitDiv set to $08
ldhx #$033D
sthx UnitEmpt ;UnitEmpt set to $03; UnitFull set to $3D
lda #$01
jsr lcdcmdo ;clear LCD
ldhx #msg03b
jsr lcdstro ;and show choice selection to be in
jsr del1s ;wait 1s
jmp LEVEL ;let's do LEVEL now...
;__________________________________________________________
;__________________________________________________________
;__________________________________________________________
;********************************************************************
;********************************************************************
;******** GENERAL Routines ******************************************
;********************************************************************
;********************************************************************
;-------- INITIALIZATION Routines -----------------------------------
; ALLINIT: initializes HC08, sets I/O, resets LCD and LEDs
; -------
ALLINIT: bset 0,config1 ;disable COP
mov #$38,ddra ;PTA0=MPAK,PTA1=SEL,PTA2=ENT,PTA3=E,PTA4=RS,PTA5=clk
mov #$30,adiclk ;ADC clock /2
bclr 3,porta ;E=0
bclr 4,porta ;grn=OFF; RS=0
bclr 5,porta ;red=OFF; CLK=0
rts
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; WARMUP: waits half a second while it flashes LEDs, and allows LCD to get ready
; ------
WARMUP: bclr 4,porta
bclr 5,porta ;LEDs off
lda #$0A ;prepare to do this 10x
tenx: jsr del25ms ;delay
bclr 4,porta
bset 5,porta ;alternate on/off
jsr del25ms
bset 4,porta
bclr 5,porta ;and off/on
dbnza tenx ;10 times so the LCD can get ready (slow startup)
jsr lcdinit ;now initialize it
AN1950
Sensors
18 Freescale Semiconductor
bclr 4,porta
bclr 5,porta ;LEDs off
rts
;-------- WRITE TO EEPROM Routines ----------------------------------
; wrflash: burns A into flash at location pointed by H:X
; -------
wrflash: sthx flshadr ;this is the address in the flash
sta flshbyt ;and the byte we want to put there
tsx
sthx memSP ;store SP in memSP, so it can be temporarily used as a 2nd index register
ldhx #ramfree+1 ;SP now points to RAM (remember to add 1 to the address!!!, HC08 quirk)
txs ;SP changed (careful not to push or call subroutines)
ldhx #ersflsh ;H:X points to beginning of flash programming code
doall: lda 0,x ;get 1st byte from flash
sta 0,sp ;copy it into RAM
aix #$0001 ;HX:=HX+1
ais #$0001 ;SP:=SP+1
cphx #lastbyt ;and continue until we reach the last byte
bne doall
ldhx memSP ;once done, restore the SP
txs
jsr ramfree ;and run the subroutine from RAM, you cannot write the flash while
rts ;running a code in it, so the RAM has to take over for that piece
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;*************** THE FOLLOWING CODE WILL BE COPIED INTO AND WILL RUN FROM RAM ******
ersflsh: lda #$02 ;textbook way to erase flash
sta flcr
lda flbpr
clra
ldhx flshadr
sta 0,x
bsr delayf
lda #$0A
sta flcr
bsr delayf
lda #$08
sta flcr
bsr delayf
clra
sta flcr
bsr delayf
pgmflsh: lda #$01 ;textbook way to program flash
sta flcr
lda flbpr
clra
ldhx flshadr
sta 0,x
bsr delayf
lda #$09
sta flcr
bsr delayf
lda flshbyt
ldhx flshadr
sta 0,x
bsr delayf
lda #$08
sta flcr
bsr delayf
clra
sta flcr

KITMPVZ5004EVK

Mfr. #:
Manufacturer:
NXP / Freescale
Description:
Pressure Sensor Development Tools WATER LEVEL BOARD
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet