CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

concatinating two int8's into an int16

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SerialGmr8



Joined: 30 Nov 2007
Posts: 13

View user's profile Send private message

concatinating two int8's into an int16
PostPosted: Mon Dec 03, 2007 3:31 pm     Reply with quote

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







PostPosted: Mon Dec 03, 2007 3:42 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 03, 2007 6:17 pm     Reply with quote

surely worth a shot.
thanks frequentguest...

*you might as well sign up :P*
Ttelmah
Guest







PostPosted: Wed Dec 05, 2007 5:26 am     Reply with quote

As a comment on what may be wrong, what is setting 'i'...

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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