Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

at89c51...help

Status
Not open for further replies.

baftab

New Member
CODE1
org 000h
mov p0,#00h
mov p1,#11110111b
bil:jnb p0.0,bil
mov p1,#11100110b
end

CODE2
org 000h
mov p0,#0ffh
mov p1,#11110111b
bil:jnb p0.0,bil
mov p1,#11100110b
end

i want to use p0.0 as an input pin, and when it goes high the data to p1 shud change

when i use code 2, it doesnt work...the data changes without p0.0 getting a high

using code1 works...but ...to make a port an input port...we hav to send all 1's...so what is going wrong???
 
It appears that codes 1 and 2 are the same. Also, it would be more helpful to other reader's eyes if you include your code like this:

code 1:
Code:
org 000h
mov p0,#00h
mov p1,#11110111b
bil:jnb p0.0,bil
mov p1,#11100110b
end

CODE 2:
Code:
org 000h
mov p0,#0ffh
mov p1,#11110111b
bil:jnb p0.0,bil
mov p1,#11100110b
end
 
no..there is one difference
mov p0,#0ffh

and in other its

mov p0,#00h

this difference is causing a major difference
the one with p0,#00h is working correctly
why???
 
you need 10K pullups on port 0

You must install 10K pullups if you are using Port 0 for anything else but addressing. Look at the datasheet.
Looks like the code below should work, as long as you have pullup resistors.

Code:
org 000h
mov p0,#0ffh           ;writing ff to the port makes it an input
mov p1,#11110111b
bil:
jnb p0.0,bil
mov p1,#11100110b
end
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top