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.

plz help meeeeeee

Status
Not open for further replies.

muralistarshine

New Member
i was working with 89c51 and i have to set the bit p1.4 for both of the bits p2.3 and p2.4 on
if only p2.3 i have to set bit p1.3

i need to implement as model to execute my project work can above program can be done on hardware???????

org 0000h
back:
jb p2.3,led1
sjmp back
led1:
jb p2.4,led2
setb p1.3
led2:
setb p1.4
end


plz help meeeee
 
Why did you create a new post on the same subject, where people have already answered you? This is worst than double posting.
 
You mean
a) P2.3 and P2.4 ON = Set P1.4
b) P2.3 ON = Set P1.3
right?

I see multiple problems on your code:
1) It runs only once since there's no endless loop
2) Both P1.3 & P1.4 will always be ON since there's no jump after setting P1.3
3) You never reset P1.3 & P1.4 is that normal?
 
Beside what Hayato mentioned in your other thread regarding the same problem this would be fine.
Loop:
JNB P2.3, ResetAll
SETB P1.3
JNB P2.4, Loop
SETB P1.4
JMP Loop

ResetAll:
CLR P1.3
CLR P1.4
JMP Loop

Gee, that's a looooooooooooooooooooooong time I ever wrote ASM code :)
 
modify mr. rushi53 code use as switch

for me , i modify rushi53rushi53 code to use as switch p2.3 and p2.4 if pressed mean 0 , if release mean 1 . circuit input connect 100k resistor to port 2.3 and port 2.4 , each port 2.3 and 2.4 connect to a switch then to ground(GND).
for output led , cathode connect to a 330 ohm resistor anot connect to 5v VCC.
Code:
            org 0000h
	    setb p2.3
	    setb p2.4

back:       jnb p2.3,ledp13on
            clr p1.3
            clr p1.4
            sjmp back

ledp13on:   jnb p2.4,ledp14on
            setb p1.3
            clr p1.4
            sjmp back

ledp14on:   setb p1.3
            setb p1.4
            sjmp back
            end

the led on when :-
p2.3=0 ,p1.3 led on
p2.3 & 2.4 =0 ,p1.3 & 1.4 led on

switch pressed = 0
switch release(no press) = 1

comment if something wrong i will reply as soon as possible
 
Last edited:
for me , i modify rushi53rushi53 code to use as switch p2.3 and p2.4 if pressed mean 0 , if release mean 1 . circuit input connect 100k resistor to port 2.3 and port 2.4 , each port 2.3 and 2.4 connect to a switch then to ground(GND).
for output led , cathode connect to a 330 ohm resistor anot connect to 5v VCC.
Code:
            org 0000h
	    setb p2.3
	    setb p2.4

back:       jnb p2.3,ledp13on
            clr p1.3
            clr p1.4
            sjmp back

ledp13on:   jnb p2.4,ledp14on
            setb p1.3
            clr p1.4
            sjmp back

ledp14on:   setb p1.3
            setb p1.4
            sjmp back
            end

the led on when :-
p2.3=0 ,p1.3 led on
p2.3 & 2.4 =0 ,p1.3 & 1.4 led on

switch pressed = 0
switch release(no press) = 1

comment if something wrong i will reply as soon as possible

This is what your code does:

Switch 2.3 unpressed:
LED 1.3 = ON
LED 1.4 = ON

Switch 2.3 pressed:
LED 1.3 = ON
LED 1.4 = ON

Switch 2.4 pressed:
LED 1.3 = ON
LED 1.4 = ON

Why, do you ask.
Because you are always going back to the "back" loop.

Lets summarize:
1.3 = 0 -> LED1 ON
1.3 = 1 -> LED1 OFF
1.4 = 0 -> LED2 ON
1.4 = 1 -> LED2 OFF
2.3 = 0 -> SW1 PRESSED
2.3 = 1 -> SW1 UNPRESSED
2.4 = 0 -> SW2 PRESSED
2.4 = 1 -> SW2 UNPRESSED

Conditions mentioned by the OP
SW1 PRESSED -> ONLY LED1 ON
SW1 & SW2 PRESSED -> ONLY LED2 ON

Code:
 org 0000h
	    setb p2.3 ;INPUT
	    setb p2.4 ;INPUT
	    setb p1.3 ;TURN LED1 OFF
	    setb p1.4 ;TURN LED2 OFF

START: jnb p2.3,ledp13on ;if SW1 pressed, goto ledp13on
            jnb p2.4,ledp14on ;if SW2 pressed, goto ledp14on
            sjmp START

ledp13on:jnb p2.4,ledp14on ;if SW2 pressed, goto ledp14on else turn LED1 ON only
              clr p1.3
              setb p1.4
              sjmp START

ledp14on:jb p2.3, START ;IF SW2 = pressed and SW1 = unpressed, nothing happens, else turn LED1 &2 ON
              clr p1.3
              clr p1.4
              sjmp START
              end

Don't forget the debounce routines, and to initializate the uC.
 
Status
Not open for further replies.

Latest threads

Back
Top