I have a word (16 bits) that I want to break into 4 bytes, i.e.
word = dddd cccc bbbb aaaa
convert to
byte1 = 0000 aaaa
byte2 = 0000 bbbb
byte3 = 0000 cccc
byte4 = 0000 dddd
any sugestions on how I would go about doing this?
I have a word (16 bits) that I want to break into 4 bytes, i.e.
word = dddd cccc bbbb aaaa
convert to
byte1 = 0000 aaaa
byte2 = 0000 bbbb
byte3 = 0000 cccc
byte4 = 0000 dddd
any sugestions on how I would go about doing this?
There's as many ways to do this as there are readers on this forum... here's just one way...
Byte1=Myword.Lowbyte & $0F
Byte2=Myword.Lowbyte >> 4
Byte3=Myword.Highbyte & $0F
Byte4=Myword.Highbyte >> 4
Thanks Melanie, I forgot about variable modifiers. Your solution appears that it will work however when I compile the code I get the following error ...
Error[101] C:\PROGRAM FILES\PICBASIC\PBPPIC12.LIB 5693 :
ERROR: (Library cannot exceed first 256 words.)
This seems to be caused by the ">>" (shift right) command. Any thoughts?
Compiles fine without error for me.
You running a demo or otherwise restricted version of PICBasic?
or you run out of the RAM capability on your 12XXXX PIC.
Post your whole code here and PIC model, we'll have a look to that.
Compile ok here to.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I'm using PICBasic Pro 2.46 and programming a 16F59. I really can't show the entire code (because it is for work). However, its not that large and an associate told me he has always had problems with << and >> so he shifts bits in assembly language, ie. RRF _MyVariable, 1. Do you know what that error message means? Is there a complete list of error codes published ?
Bookmarks