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 CCS Technical Support

help with writing "shift_right" in regular c langu

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



Joined: 04 Apr 2011
Posts: 3

View user's profile Send private message

help with writing "shift_right" in regular c langu
PostPosted: Mon Apr 04, 2011 8:01 am     Reply with quote

Hello!

i have a problem with this function:

shift_right(RFbuffer+RFbuffer_index, 1, bitValue)

Can anyone please explain what it does? i understand that it should shift the bit's right, but not what happens when you write "RFbuffer+RFbuffer_index" as the variable.

I am currently working on a RFID reader using the CCS code for EM4095. And my problem is that i don't have very much experience using the CCS compiler, so i'm trying to write the code in knudsen C compiler.

I would be very grateful if someone could help me! Smile
_________________
student at Høyskolen i Gjøvik
gautel



Joined: 04 Apr 2011
Posts: 3

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 8:05 am     Reply with quote

i should add that "RFbuffer" is an array, and "RFbuffer_index" is an integer!
_________________
student at Høyskolen i Gjøvik
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 9:10 am     Reply with quote

It shifts right the single byte at character location 'RFbuffer_index', in the array 'Rbuffer', shifting _in_ the value 'bitValue' to the vacated space, and returns the bit shifted out the bottom.
Since RFBuffer is int8, it'd be roughly equated in ANSI C by:
Code:

int8 shift_right(int8 *locn, int8 count, int8 val){
    int8 rval=0
    if (locn[count] & 1)
         rval=1; //value to return
    locn[count]/=2; //use division, since in C no guarantee that >>
    //does not wrap.
    if (val)
         locn[count]|=128;
    return rval;
}
   


Best Wishes
gautel



Joined: 04 Apr 2011
Posts: 3

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 9:29 am     Reply with quote

Thank you very much for the help! Very Happy
_________________
student at Høyskolen i Gjøvik
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