Click here to Skip to main content
15,888,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a conflict in portc will shifted with a value 1
and 1 will shifted with the value of portc

What I have tried:

i have tried in 7 segments and reverses problems
Posted
Updated 9-Jul-23 5:19am
Comments
PIEBALDconsult 9-Jul-23 10:41am    
42
Andre Oosthuizen 9-Jul-23 12:51pm    
:)

1 solution

The left shift operator A << B moves the bits of operand A by B places to the left: it multiplies A by 2B

For example if A is 4 (i.e. binary 00000100) and B is 3, then A << B will return 32 (or binary 0100000)

So your two instructions do very different things:
1 << portc returns a single bit set at a position determined by teh value of portc
portc << 1 multiplies the value of portc by two.

The rest is obvious: the A |= B operator performs a bitwise OR between A and B and assigns the result to A.

I think you need to work out exactly what you need the code to do, and work out how to do that, rather than just randomly swapping operands over! I'd start by finding out what portc is used for and what it actually contains: I suspect you are using it very wrongly - but without the code we can;t tell.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900