Keil Logo

Logic Characters code

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Alex Wrightson
Posted
18-Oct-2005 13:51 GMT
Toolset
C51
New! Logic Characters code
Hi

What is the code used to say port2 = port2 anded with 0x7f This will clear all bits of port 2 but bit 7?

I thought it was

P2 &= 0x7f

this doesnt work, so i tried

P2 = (P2 && x7f)

This also didnt work. Anyone know what it is?
Read-Only
Author
erik malund
Posted
18-Oct-2005 14:14 GMT
Toolset
C51
New! RE: Logic Characters code
bible time

here are the links to "the bible"
Chapter 1
http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf

chapter 2
http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf


chapter 3
http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf

Erik
Read-Only
Author
Alex Wrightson
Posted
18-Oct-2005 14:40 GMT
Toolset
C51
New! RE: Logic Characters code
Thanks

Is there more chapters?

Alex
Read-Only
Author
erik malund
Posted
18-Oct-2005 14:49 GMT
Toolset
C51
New! RE: Logic Characters code
yes, but they are irrelevant (datasheets for 1993 vintage chips)

Erik
Read-Only
Author
Alex Wrightson
Posted
18-Oct-2005 14:50 GMT
Toolset
C51
New! RE: Logic Characters code
I forgot to mention I'm looking for the code in C also. Those 3 files dont explain the operations in c.
Read-Only
Author
m d
Posted
18-Oct-2005 15:02 GMT
Toolset
C51
New! RE: Logic Characters code
P2 &= 0x80
Read-Only
Author
Alex Wrightson
Posted
18-Oct-2005 15:08 GMT
Toolset
C51
New! RE: Logic Characters code
yeah well thats like i said, I also forgot to mention that to clear it I actually have to set the bits high because its inverted so useing what you said it would be

P2 &= 7F

which doesnt seem to work
Read-Only
Author
erik malund
Posted
18-Oct-2005 15:14 GMT
Toolset
C51
New! RE: Logic Characters code
I forgot to mention i'm looking for the code in c also. those 3 files dont explain the operations in c.
Read up on "port latch" and you will find out what the problem is. It has nothing to do with c or assembler, it has to do with hardware

erik
Read-Only
Author
Stefan Duncanson
Posted
18-Oct-2005 15:16 GMT
Toolset
C51
New! RE: Logic Characters code
"I actually have to set the bits high because its inverted"

If you want to set bits 0-6 and leave bit 7 unchanged you need to OR:

P2 |= 0x7f;

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.