This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with LPC938 ADC with EPM900

Hi. I'm trying to simulate 89LPC938's ADC with EPM900, but somehow it is not working. The code runs, but the ADC doesn't run at all. Some info below:

1. Single channel using channel 7 at Pin 2.0
2. ADC is set to start when P1.4 goes from low to high
3. Single conversion mode

My code is posted below. If anyone found an error or know what might be wrong with the code, please tell me. Thanks.

Note: Some codes such as delay functions and such are left out for easier viewing.

;Code Starts Here

P2M1 DATA 0A4H

IEN0 DATA 0A8H
IEN2 DATA 0D5H
IP1 DATA 0F8H
IP1H DATA 0F7H

ADCON0 DATA 097H
ADMODA DATA 0C0H
ADMODB DATA 0A1H
ADINS DATA 0A3H
ADLOWB DATA 0FFF0H
ADHIGHB DATA 0FFF1H
BNDSTA0 DATA 0FFEDH
ADCHIGH DATA 0FFEFH
ADCLOW DATA 0FFEEH

ADCSTART BIT P1.4

STACK SEGMENT IDATA

RSEG STACK
DS 20H ; 16 Bytes Stack

CSEG AT 0
USING 0
JMP START

ORG 083H
JMP ADCINT

RSEG PROG

START: MOV SP,#STACK-1

MOV P2,#00H
MOV P2M1,#01H
MOV IEN0,#80H
MOV IEN2,#02H
MOV IP1,#7FH
MOV IP1H,#7FH
CLR ADCSTART

;[Actual Code]

MOV TMOD,#00H

MOV R0,#0H
CALL ADCINIT

LOOP:
SETB ADCSTART
INC R0
CALL DELAY_1S
CLR ADCSTART
CALL LONGDELAY
JMP LOOP

;[ADC]

ADCINIT:
MOV ADCHIGH,#0FFH
MOV ADCLOW,#0H

MOV ADMODA,#10H
MOV ADMODB,#02H
MOV ADINS,#80H
MOV BNDSTA0,#80H
MOV ADCON0,#0D6H
RET

;[Interrupt Initialization]

ADCINT :
CALL ADCFUNCTION
RETI

;[Interrupt Functions]

ADCFUNCTION:
MOV R1,ADHIGHB
MOV R2,ADLOWB

MOV ADCON0,#0D6H
MOV ADMODA,#10H
RET

END

0