Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

How to read data from MCS-51's pin port?

Status
Not open for further replies.

Jasper Chow

Junior Member level 3
Joined
Nov 14, 2013
Messages
26
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Activity points
218
I want to read data from MCS51 's pin instead of the output latch, but I find no relavent instructions to accompish this task. MOV, ORL only handle the data stored in the output latch, but not the pin. I want to create a program to detect the pin's level, what should I do? I Just couldn't understand why there is no input latch and why many programs use if(P0^0==0) to test the level of the p0^0 pin. For me, what the if sentence tests is the value of the latch, which is pointless.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,478
Helped
14,047
Reputation
28,349
Reaction score
12,702
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,115
MOV, ORL only handle the data stored in the output latch, but not the pin.
True for ORL, wrong for MOV. Read the 8051 manual thoroughly!
 

Jasper Chow

Junior Member level 3
Joined
Nov 14, 2013
Messages
26
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Activity points
218
True for ORL, wrong for MOV. Read the 8051 manual thoroughly!
Could you tell me how to read in the logic level from the pin with mov, and better with keil C. I couldn't figure it out..
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,478
Helped
14,047
Reputation
28,349
Reaction score
12,702
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,115
According to MCS51 documentation, a basic MOV from port (or a respective C assignment) always reads the pin level rather than the latch state.
 

djc

Full Member level 6
Joined
Jan 27, 2013
Messages
399
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Activity points
4,507
i AM NOT SO COMFORTABLE WITH assembly language though, try ANDING port pin with binary 1, if result is 1, condition is satisfied,else condition is false.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top