|
|
View previous topic :: View next topic |
Author |
Message |
SerialGmr8
Joined: 30 Nov 2007 Posts: 13
|
concatinating two int8's into an int16 |
Posted: Mon Dec 03, 2007 3:31 pm |
|
|
Hello C gurus,
im trying to merge two int8 values into an int16 as follows;
Code: |
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
int8 storetemp[6]{0,1,2,3,4,5,6}
int8 i,s=0;
int8 tempmsb, templsb;
int16 templong;
main
{
while(1)
{
for(s=0; s<6; s++)
{
templong = storetemp[s++];
tempmsb = templong;
send(tempmsb);
strobe_SND();
templong = templong<<8;
templong = templong & 0xFF00;
templong = templong | storetemp[i];
templsb = templong;
send(templsb);
strobe_SND();
}
}
}
|
however, the values i obtain from templsb & tempmsb are garbage. I've serached a few of the threads, but havent been able to apply anything ive seen in there to help me. As im calling out to you. Kindly advise.
best regards, |
|
|
frequentguest Guest
|
|
Posted: Mon Dec 03, 2007 3:42 pm |
|
|
I didn't look at what you had done, but CCS has a built-in function to create an int16 from two int8. Look up make16() in the manual or help file. |
|
|
SerialGmr8
Joined: 30 Nov 2007 Posts: 13
|
|
Posted: Mon Dec 03, 2007 6:17 pm |
|
|
surely worth a shot.
thanks frequentguest...
*you might as well sign up :P* |
|
|
Ttelmah Guest
|
|
Posted: Wed Dec 05, 2007 5:26 am |
|
|
As a comment on what may be wrong, what is setting 'i'...
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|