Problem Data table on MCS09SH8

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem Data table on MCS09SH8

872 次查看
Eliud
Contributor I

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

标签 (1)
0 项奖励
回复
1 回复

752 次查看
bigmac
Specialist III

Hello,

 

Your code is virtually unreadable because of lack of formatting, and with no comments about the operation of your code.  These are mandatory requirements.

 

I think that the issue may be related to the fact that the ADC result is proportional to the Vdd level, whereas I seem to recall that the LM35 provides an output voltage variation in millivolts per degree, independent of the supply voltage. Changing from Vdd of 3.3 volts to 5 volts will result in a lower ADC reading at a given temperature, by a factor of 3.3 / 5 = 0.66.  Of course, the Vdd level to the MCU must be accurately regulated.

 

For cases where Vdd is not regulated, it is possible to compensate for the actual Vdd level, by separately measuring the voltage reference within the MCU.

 

Regards,

Mac

 

0 项奖励
回复