Eliud Gonzalez

Problem Data table on MCS09SH8

Discussion created by Eliud Gonzalez on Apr 20, 2012
Latest reply on Apr 20, 2012 by bigmac

Hi, I'm woriking with the MCS09SH8, I made a code that reads the value from a lm35 , that digital value its transformed in °C, and the result it will displayed on two  7 segment displays.It works perfectly, but only when the microcontroller is connected to the BDM (JM60), the problem comes when i use just a 5V source, the numbers on the displays are messed up, they are not what I previusly defined on the table, I dont know what to do I´ve tried to define the table on the RAM and the same thing happens. Here´s my code, I will appreciate your help.


INCLUDE 'MC9S08SH8.inc'

RAM EQU $0080
ROM EQU $E000
RESET EQU $FFFE

ORG RAM
ADC DC.B 0
VOL DC.B 0
FACT DC.B 2d
DEC DC.B 0
UNI DC.B 0
AUX DC.B 0
A2 DC.B 0

ORG ROM
RST MOV #$FF,PTBDD
MOV #$FF,PTCDD
CLR PTCD
LDA #$02
STA SOPT1
CLR PTBD
MOV #$F0,ADCCFG
CLR ADCSC2
MOV #$21,ADCSC1
MOV #$02,APCTL1

LOOP MOV #255,$A0
MOV #10,$A1
JSR GETADC
MAIN LDX DEC
LDA CODE,X
STA PTBD
BSET 1,PTCD
JSR RETA
BCLR 1,PTCD
LDX UNI
LDA CODE,X
STA PTBD
BSET 2,PTCD
JSR RETA
BCLR 2,PTCD
DBNZ $A0,MAIN
DBNZ $A1,MAIN
JSR GETADC
BRA LOOP

GETADC BRCLR 7,ADCSC1,GETADC
MOV ADCRL,ADC
LDX FACT
LDA ADC
MUL
PSHX
PULH
LDX #10
DIV
PSHH
PULX
STX UNI
CLRH
LDX #10
DIV
PSHH
PULX
STX DEC
DIV
RTS

RETALDA #$EF
DBNZA *
RTS
CODEFCB$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$67

ORG RESET
DC.W RST

Outcomes