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.

Help needed on 8051 programming

Status
Not open for further replies.

ClouDxv1

Newbie level 6
Joined
May 23, 2006
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
Im writing a programme for my Atmel 89S51.
But i cant seem to get it right. As u can see frm the picture, i can jump to SWITCHON when P2.1 is grounded but i cant jump to SWITCHOFF when P2.2 is grounded.
Can anyone help me pls... this is urgent its for my FYP
Thx


**broken link removed**

FYI this is a simple programme i wrote for testing purpose.. but i cant get it working nicely.
 

make u r P2 port as in put for that u just give 0xff value to the port
mov p2,#0ffh

k...all de best
 

Hi,

8051 IO ports are bidirectional. To read from port you need to configure port for reading first. To do this you need to write 0xff to port or 1 to selected bit of port.

Another possible problem is bad physical connection.
 

Hero said:
Hi,

8051 IO ports are bidirectional. To read from port you need to configure port for reading first. To do this you need to write 0xff to port or 1 to selected bit of port.

Another possible problem is bad physical connection.

Thx for the replies..
how to i write 0xff to the ports?
Sorry im still a beginner in this programming on 8051
 

Try the following code:
Code:
                       1    $NOPAGING
                       2    $MOD252
                       3    
0000                   4                    ORG     0000h
                       5    
0000 75A0FF            6                    MOV     P2, #0FFh
                       7    
0003 759000            8    START:          MOV     P1, #00000000b
0006 30A102            9                    JNB     P2.1, SWITCH_ON
0009 80F8             10                    JMP     START
                      11    
000B 7590F8           12    SWITCH_ON:      MOV     P1, #11111000b
000E 30A2F2           13                    JNB     P2.2, START
0011 80F8             14                    JMP     SWITCH_ON
                      15    
                      16                    END

VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
P1 . . . . . . . . . . . . . . .  D ADDR  0090H  PREDEFINED  
P2 . . . . . . . . . . . . . . .  D ADDR  00A0H  PREDEFINED  
START. . . . . . . . . . . . . .  C ADDR  0003H  
SWITCH_ON. . . . . . . . . . . .  C ADDR  000BH

Regards,
IanP
 

Aftar reset P0, P1,P2 & P3 is automatically set to 0xFF, it mean all port are as input already!

JNB P2.2,SWITCHOFF
i cant jump to SWITCHOFF when P2.2 is grounded.

it mean P2.2 always in 'high' position, even you ground it!

As Hero said :
problem is bad physical connection

check P2.2 volatge when you turn on/off your switch
 

IanP said:
Try the following code:
Code:
                       1    $NOPAGING
                       2    $MOD252
                       3    
0000                   4                    ORG     0000h
                       5    
0000 75A0FF            6                    MOV     P2, #0FFh
                       7    
0003 759000            8    START:          MOV     P1, #00000000b
0006 30A102            9                    JNB     P2.1, SWITCH_ON
0009 80F8             10                    JMP     START
                      11    
000B 7590F8           12    SWITCH_ON:      MOV     P1, #11111000b
000E 30A2F2           13                    JNB     P2.2, START
0011 80F8             14                    JMP     SWITCH_ON
                      15    
                      16                    END

VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
P1 . . . . . . . . . . . . . . .  D ADDR  0090H  PREDEFINED  
P2 . . . . . . . . . . . . . . .  D ADDR  00A0H  PREDEFINED  
START. . . . . . . . . . . . . .  C ADDR  0003H  
SWITCH_ON. . . . . . . . . . . .  C ADDR  000BH

Regards,
IanP

Thx for the reply.
But i use the code u giv me and load it into the MC but it still cant jump to START when P2.2 is grounded:cry:
 

But i use the code u giv me and load it into the MC but it still cant jump to START when P2.2 is grounded:

I am sure it is a hardware problem.
Onece again : check P2.2 volatge when you turn on/off your switch
 

If you are sure that P2.2 is properly grounded and P2.1 is not grounded at the same time (if it is, you will have square wave on P1.7, .. , P1.3) and the micro doesn't want to go to START, then try another pin, say, P2.3 ..
Maybe, although very unlikely, P2.2 is damaged for some reasons ..

Regards,
IanP
 

I've check the voltage on P2.2 it shows only 0.02v while the rest of the ports shows reading of 4.97v.
So that means my P2.2 is spoilt?
 

Don't use P2.2 any more, try with all other pin except P2.2
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top