PDA

View Full Version : Basic question about Aliases



dbachman
- 14th December 2008, 01:12
I am still on a learning curve here so please bear with me.

I have been trying to make use of byte0 and byte1. Shouldn't this flash leds on portb? Must be doing something wrong.

Thanks, Don



TRISB = %00000000

loop:

x var word
x = %00101111

portb = x.byte0
pause 1000
portb = x.byte1
pause 500


Goto loop
End

Jerson
- 14th December 2008, 01:43
You've defined x as a word. That's 16 bits. You've assigned 8 bits of X. PortB is 8 bits too. X.Byte0 chooses the lower 8 bits of X and X.Byte1 chooses the higher 8 bits of X.

dbachman
- 14th December 2008, 01:47
Thanks Jerson,

I figured it was somethig simple like that. Thanks for taking the time to reply

Don

dbachman
- 14th December 2008, 01:57
Also, I was trying to figure if this is how this worked.

X = %00001111

X = X | %010000000

Is %01001111 the value of X now?

Thanks, Don

Jerson
- 14th December 2008, 06:36
that is correct.