Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hex keypad decoder problem

Status
Not open for further replies.

zhi_yi

Full Member level 4
Full Member level 4
Joined
Feb 2, 2005
Messages
196
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,548
Hi there, please help me

i intended to make a 4x4 hex decoder using at89s2051, after i made the program, i tried it on at89s52, and it's work, but when i tried to write the hex file into at89s2051 and tried it on the circuit, it didn't work, i use asm language, i've changed the header into $MOD2051, the result is still some error occured, while i press button 0 until 7, it's work, but from 8 to F the errors occured. please help me.

any helps are very appreciated.

thank you :)
 

Maybe you used something that exists in the 89C52 and doesn't exist in the 89C2051 .. After all 89C2051 is the reduced version of 51 - not to mention 52 ..

Could you post your code?

Regards,
IanP
 

of course, here is the code, please help me where is the mistake.. while i press on keypad 0 until 7, it's work with no errors, but up to 7, the output always 1010

$MOD2051
$OBJECT

ROW0 EQU P1.0
ROW1 EQU P1.1
ROW2 EQU P1.2
ROW3 EQU P1.3

ALERT EQU P3.7

ORG 00H
AJMP START

START:
SETB ALERT
;-------------------------------WAIT TILL KEY RELEASED-------------------------------------------
MAIN1:
MOV P1,#0F0H
MOV A,P1
ANL A,#11110000B
CJNE A,#11110000B,MAIN1
;-------------------------------WAIT TILL KEY PRESSED--------------------------------------------
LOOP1:
ACALL DELAY
MOV A,P1
ANL A,#11110000B
CJNE A,#11110000B,CHECK_BOUNCE
AJMP LOOP1
CHECK_BOUNCE:
ACALL DELAY
MOV A,P1
ANL A,#11110000B
CJNE A,#11110000B,CHECK_BARIS
AJMP LOOP1
;-------------------------------------SCAN BARIS-------------------------------------------------
CHECK_BARIS:
CLR ROW0
SETB ROW1
SETB ROW2
SETB ROW3

MOV A,P1
ANL A,#11111110B
CJNE A,#11111110B,BARIS_0

;------------------------------------------------------------------------------------------------
SETB ROW0
CLR ROW1
SETB ROW2
SETB ROW3

MOV A,P1
ANL A,#11111101B
CJNE A,#11111101B,BARIS_1 ;CEK ROW 1
;------------------------------------------------------------------------------------------------
SETB ROW0
SETB ROW1
CLR ROW2
SETB ROW3

MOV A,P1
ANL A,#11111011B
CJNE A,#11111011B,BARIS_2 ;CEK ROW 2
;------------------------------------------------------------------------------------------------
SETB ROW0
SETB ROW1
SETB ROW2
CLR ROW3

MOV A,P1
ANL A,#11110111B
CJNE A,#11110111B,BARIS_3 ;CEK ROW 3
AJMP LOOP1
;------------------------------------------------------------------------------------------------
BARIS_0:
MOV DPTR,#ISI_ROW0
AJMP FIND_CLMN
BARIS_1:
MOV DPTR,#ISI_ROW1
AJMP FIND_CLMN
BARIS_2:
MOV DPTR,#ISI_ROW2
AJMP FIND_CLMN
BARIS_3:
MOV DPTR,#ISI_ROW3
AJMP FIND_CLMN
;------------------------------------------------------------------------------------------------

FIND_CLMN:
RLC A
JNC FOUND
INC DPTR
AJMP FIND_CLMN
;------------------------------------------------------------------------------------------------
FOUND:
MOV A,#00H
MOVC A,@A+DPTR
MOV P3,A
;MOV P0,A
CLR ALERT
ACALL DELAY
ACALL DELAY
ACALL DELAY
SETB ALERT
LJMP START
;-------------------------------------DELAY------------------------------------------------------
DELAY:
MOV R0,#36
DELAY1:
MOV R1,#0FFH
DJNZ R1,$
DJNZ R0,DELAY1
RET
;------------------------------------DEFINE DATA-------------------------------------------------

ORG 350H
ISI_ROW0: DB 0H,1H,2H,3H
ISI_ROW1: DB 4H,5H,6H,7H
ISI_ROW2: DB 8H,9H,0AH,0BH
ISI_ROW3: DB 0CH,0DH,0EH,0FH

END
 

In general, you don't have problem with software ..
As you have said, with 89C52 it worked fine ..
Somewhere in the code you use P3 - I don't think you can use P3 as a PORT ..
Instead of using MOV P3,A try to shift bits (through C-flag) ACC.0 to P3.0, ACC.1 to P3.1 and so on ..

Regards,
IanP
 

thank you,
i changed the "mov p3,a" to these code using carry flag :

FOUND:
MOV A,#00H
MOVC A,@A+DPTR

BIT3A:
RRC A
JNC BIT3
SETB P3.0
JMP BIT2A
BIT3:
CLR P3.0
BIT2A:
RRC A
JNC BIT2
SETB P3.1
JMP BIT1A
BIT2:
CLR P3.1
BIT1A:
RRC A
JNC BIT1
SETB P3.2
JMP BIT0A
BIT1:
CLR P3.2
BIT0A:
RRC A
JNC BIT0
SETB P3.3
JMP ASDF
BIT0:
CLR P3.3

ASDF:

CLR ALERT
ACALL DELAY
ACALL DELAY
ACALL DELAY
SETB ALERT
LJMP START

but the result is still the same, it's work fine from 0 to 7, but from 8 to F there are some errors occured. is it because of pin port 1.1 and 1.0 could be uses as analog comparator, and it affected to my row scanning circuit? how to use the port 1.1 (AIN1) and port 1.0 (AIN0) as digital input/output?

thank you very much
 

It looks like it is not software related problem ..
So, lets try this:
Port 1 is an 8-bit bi-directional I/O port ..
Port pins P1.2 to P1.7 provide internal pull-ups ..
P1.0 and P1.1 requires external pull-ups ..
Do you have them?
If you don't, connect 4.7kΩ - 10kΩ pull-ups and try again ..

Regards,
IanP
 

    zhi_yi

    Points: 2
    Helpful Answer Positive Rating
i gave pull up resistor to these port, and the circuit works well,

thank you very much :)

God Bless You :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top