I have code that is not working for the MC68HC12, it takes 0-5V into the
ADC and does some math to convert to revolutions per second and outputs
to 2 LED's. Could someone analyze the code to tell me in general what
might be wrong with the code. Some where I've think I've made a basic
mistake, I have not used the ADC before. I get not display on LED's.
The code is also attached.
include 'MC9S12C128.inc' org $800 movb #$FF, DDRB movb #$C0, ATDCTL2 movb #$00, ATDCTL3 movb #$00, ATDCTL4 ldaa #1Wait deca bne Wait movb #$20, ATDCTL5 ldab ATDDR0H ;AB will hold the input loop clra ;clear AA- AB holds converted input ldab #$80 ;test data -to be commented out ldx #51 ;relationship between digital number and BCD idiv ;as defined in prelab stx holder ;holder holds the ones place ldaa #10 ;there will be a remainder. Want at least 1 decimal point accuracy mul ldx #51 ;repeat dividing by 51 idiv stx holder2 ;holder2 holds the tenths place ldd holder ;what follows is multiplying both the ones and teneths place by (18/5) ldy #18 ;as shown in pre-lab work emul std holder ldd holder2 ldy #18 emul std holder2 ldd holder ldx #5 idiv stx holder ldd holder2 ldx #5 idiv stx holder2 ldd holder2 ;we then want to divide holder2 (tenths place) by 10 and add it to holder ldx #10 ;in order to get 1 number with which to continue calculation of RSP idiv xgdx addd holder std Va ldd #14 ;we want to add 1.4 to Va, per pre-lab work. divide 14 by 10 to achieve this ldx #10 idiv stx holder std holder2 ;remainder stored in holder2 ldd Va addd holder std Va ldd holder2 ldx #10 idiv ldd Va addd 0,x std Va ldy #2 ;multiply by 2 emul std Va ldd #46 ;multiply by .46 = (46/100) ldx #100 idiv stx Va ;Va now contains RPS ldd Va cpd #10 bge output1 ldaa #00 output1 ldd Va ;checks value of tens place of RPS ldx #10 idiv stx tensplace ldd tensplace cpd #1 beq one1 ldd tensplace cpd #2 beq two1 ldd tensplace cpd #3 beq three1 ldd tensplace cpd #4 beq four1 ldd tensplace cpd #5 beq five1 ldd tensplace cpd #6 beq six1 ldd tensplace cpd #7 beq seven1 ldd tensplace cpd #8 beq eight1 ldd tensplace beq nine1 ldaa #00 one1 ldaa one ;will load appropriate hex number to have 7-seg display output two1 ldaa two ;appropriate numberthree1 ldaa threefour1 ldaa fourfive1 ldaa fivesix1 ldaa sixseven1 ldaa seveneight1 ldaa eightnine1 ldaa nine staa tensplace ldd Va ;checks value of tens place of RPS ldx #10 idiv stx onesplace ldd onesplace cpd #1 beq one2 ldd onesplace cpd #2 beq two2 ldd onesplace cpd #3 beq three2 ldd onesplace cpd #4 beq four2 ldd onesplace cpd #5 beq five2 ldd onesplace cpd #6 beq six2 ldd onesplace cpd #7 beq seven2 ldd onesplace cpd #8 beq eight2 ldd onesplace beq nine1 ldaa #00 one2 ldaa one ;will load appropriate hex number to have 7-seg display output two2 ldaa two ;appropriate numberthree2 ldaa threefour2 ldaa fourfive2 ldaa fivesix2 ldaa sixseven2 ldaa seveneight2 ldaa eightnine2 ldaa nine staa onesplace movb #$7C, DDRCAN ;configure portcan for output (from textbook) movb #$FF, DDRP ;configure portp for output movb tensplace, PORTP ;place tens-place output code on portp movb #$40, PORTCAN ;activate pcan6 so that led will illuminate with tensplace digit movb #$30, PORTCAN ;activate pcan5 movb onesplace, PORTP ;illuminate ones-place output code lbra loop swiholder rmb 2 holder2 rmb 2Va rmb 2tensplace rmb 1onesplace rmb 1zero equ $7Eone equ $30two equ $6Dthree equ $79four equ $33five equ $5Bsix equ $5Fseven equ $70eight equ $7Fnine equ $7B PORTP equ $56PORTCAN equ $13E DDRCAN equ $13F