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.

coding

Status
Not open for further replies.

garv3007

New Member
how can i convert 8 bit input data to 4 bit data for output to 4 bit encoder which is interfaced with 8051..
 
value is stored in a register..
i am using 4 bit of port 2 to interface with 4 bit encoder.
suppose value is in reg. R0
then..
mov p2, R0;
how can i give a decimal no to port 2
 
can you explain. plz

Explain what? It's just a code snippit, not a complete program. The first line sends the lower 4 bits, second line places the upper 4 bits in the lower portion, and third line sends the newly placed for bits. So, for example, for 53H, it sends the "3" and then the "5". Sending Decimal 83 doesn't solve you problem.
 
value is stored in a register..
i am using 4 bit of port 2 to interface with 4 bit encoder.
suppose value is in reg. R0
then..
mov p2, R0;
how can i give a decimal no to port 2

In that case, you do

mov p2, R0

then you shift the value of R0, using whatever shift instruction you have, for example

SR R0
SR R0
SR R0
SR R0

Where SR is a "shift right" instruction.

then do mov p2, R0 again.

You can also do a divide by 16 instruction in place of the SR instructions.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top