soohino
Newbie level 2

Im doing a project that deals with ADC>microC8052>latch>7 segment displays.
basically, the analog data that i obtained from my sensor will be sent to ADC to do the conversion becoming an digitised data.after that the digitised data will be sent to microC to do data conditioning and only will output the data to 7 segment displays through latches(i have 3 latches for 3 digits data, output range would be from 0.00 till 5.00V).
Today i have programmed my microcontroller and tested with my circuit in breadboard.however, it doesnt work.i dont know what is wrong with it. i assume there is something wrong with my assembly language programming. Anyone there can help me to debug and correct my fault??
below is my assembly language:
;RD - P3.0
;WR - P3.1
;INTR - P3.2
;--------------------------------------------------------------------------------------
ENTRY EQU 30H
L1 EQU 31H
L2 EQU 32H
L3 EQU 33H
ORG 00H
MOV P1,#0FFH ;P1 IS INPUT PORT
LOOP:
SETB P3.2 ;SET INTR TO HIGH
CLR P3.1 ;PREPARE FOR A/D CONVERSION
SETB P3.0 ;SET READ TO HIGH
SETB P3.1 ;START A/D CONVERSION
WAITFORDONE:
JB P3.2,WAITFORDONE ;WAIT UNTIL CONVERSION IS DONE
CLR P3.0 ;LOAD 8-BIT VALUE TO ADC OUTPUTS
MOV ENTRY,P1 ;READ ADC OUTPUTS
MOV P2,#3FH ;SHOW '0'AT ALL 7 SEGMENT DISPLAYS AS INITIALIZATION
CLR P3.3
CLR P3.4
CLR P3.5
SETB P3.3
SETB P3.4
SETB P3.5
LCALL START_1
LCALL START_2
LCALL START_3
AJMP LOOP
START_1:
MOV A,ENTRY ;TRANSFER THE ADC OUTPUT TO P2
LCALL LOOK_UP_L1
MOV L1,A ;TRANSFER THE OUTPUT TO LATCH-1 AS FIRST DIGIT
MOV P2,L1
CLR P3.3
SETB P3.3
RET
LOOK_UP_L1:
INC A
MOVC A,@A+PC
RET
TABLE_L1:
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,5BH,5BH, DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,
DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH, DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,
DB 5BH,5BH,5BH,5BH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H
START_2:
MOV A,ENTRY
LCALL LOOK_UP_L2
MOV L2,A
MOV P2,L2
CLR P3.4
SETB P3.4
RET
LOOK_UP_L2:
INC A
MOVC A,@A+PC
RET
TABLE_L2:
DB 3FH,3FH,3FH,3FH,3FH,06H,06H,06H,06H,06H,5BH,5BH,5BH,5BH,5BH,
DB 5BH,4FH,4FH,4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5BH,66H,7DH,
DB 7FH
END
There are 3 look up tables i used. Say, if the reading is 2.35V, the microcontroller will get the 2 in hexa in look_up_L1. then digit 3 from look up L2. and digit 5 from look up L3. then they will be displayed in my 7 segment displays.
basically, the analog data that i obtained from my sensor will be sent to ADC to do the conversion becoming an digitised data.after that the digitised data will be sent to microC to do data conditioning and only will output the data to 7 segment displays through latches(i have 3 latches for 3 digits data, output range would be from 0.00 till 5.00V).
Today i have programmed my microcontroller and tested with my circuit in breadboard.however, it doesnt work.i dont know what is wrong with it. i assume there is something wrong with my assembly language programming. Anyone there can help me to debug and correct my fault??
below is my assembly language:
;RD - P3.0
;WR - P3.1
;INTR - P3.2
;--------------------------------------------------------------------------------------
ENTRY EQU 30H
L1 EQU 31H
L2 EQU 32H
L3 EQU 33H
ORG 00H
MOV P1,#0FFH ;P1 IS INPUT PORT
LOOP:
SETB P3.2 ;SET INTR TO HIGH
CLR P3.1 ;PREPARE FOR A/D CONVERSION
SETB P3.0 ;SET READ TO HIGH
SETB P3.1 ;START A/D CONVERSION
WAITFORDONE:
JB P3.2,WAITFORDONE ;WAIT UNTIL CONVERSION IS DONE
CLR P3.0 ;LOAD 8-BIT VALUE TO ADC OUTPUTS
MOV ENTRY,P1 ;READ ADC OUTPUTS
MOV P2,#3FH ;SHOW '0'AT ALL 7 SEGMENT DISPLAYS AS INITIALIZATION
CLR P3.3
CLR P3.4
CLR P3.5
SETB P3.3
SETB P3.4
SETB P3.5
LCALL START_1
LCALL START_2
LCALL START_3
AJMP LOOP
START_1:
MOV A,ENTRY ;TRANSFER THE ADC OUTPUT TO P2
LCALL LOOK_UP_L1
MOV L1,A ;TRANSFER THE OUTPUT TO LATCH-1 AS FIRST DIGIT
MOV P2,L1
CLR P3.3
SETB P3.3
RET
LOOK_UP_L1:
INC A
MOVC A,@A+PC
RET
TABLE_L1:
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,3FH,
DB 3FH,3FH,3FH,3FH,3FH,3FH,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,
DB 06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,06H,5BH,5BH, DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,
DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH, DB 5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,5BH,
DB 5BH,5BH,5BH,5BH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,
DB 4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,4FH,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,66H,
DB 66H
START_2:
MOV A,ENTRY
LCALL LOOK_UP_L2
MOV L2,A
MOV P2,L2
CLR P3.4
SETB P3.4
RET
LOOK_UP_L2:
INC A
MOVC A,@A+PC
RET
TABLE_L2:
DB 3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,07H,6FH,06H,4FH,6DH,07H,
DB 6FH,06H,4FH,6DH,07H,6FH,3FH,5BH,66H,7DH,7FH,3FH,5BH,66H,7DH,
DB 7FH
END
There are 3 look up tables i used. Say, if the reading is 2.35V, the microcontroller will get the 2 in hexa in look_up_L1. then digit 3 from look up L2. and digit 5 from look up L3. then they will be displayed in my 7 segment displays.