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

Pointer to int16

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



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

Pointer to int16
PostPosted: Mon Jul 13, 2009 5:38 am     Reply with quote

I'm having a problem with pointers to 16 bit variables.

var1 is a RAM address, say 0x0800
var2 is the data that I would like to store at that address.

If I do this:
Code:
*var1=var2;
I lose the MS byte of my data.

If I do this, however, I get the desired result.
Code:
*var1=var2;
var1++;
*var1=var2>>8;


My question: is there a 'smarter' way to do this? Have I not read the manual fully? Embarassed

var1 and var2 are declared as int16.
I'm using PCD for a dsPIC30F2010.

Thanks.
Rohit
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 13, 2009 5:51 am     Reply with quote

Whoops! I should've declared var1 as int16*. This is what happens if you sit for 12 hours straight looking at piles of C Rolling Eyes

Rohit
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