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

Will this statement work ??

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



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

Will this statement work ??
PostPosted: Sat Dec 12, 2009 1:35 am     Reply with quote

Hi,

As per the code below , a high state on MMC_DI sets a bit while a low state clears the bit...correct ??

Code:
 shift_left(in,1,input(MMC_DI));


Now I need to modify the above statement so that a high on MMC_DI should clear the bit, while a low state sets the bit value.

How do I do this ??

thanks
a
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 3:15 am     Reply with quote

Did you try a C bit inverting operator?
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sat Dec 12, 2009 3:27 am     Reply with quote

Will this work ??

shift_left(in,1,!input(MMC_DI));

How to do a C bit inversion ???
Guest








Re: RE:
PostPosted: Sat Dec 12, 2009 5:58 am     Reply with quote

Quote:
How to do a C bit inversion ???


Just ex. "bit inversio"
Code:
void Tproc1(){
 int1 bit1;
 int8 byte1;

 bit1 =~bit1;
 byte1 = ~(byte1&0x01)&~0x01;
}
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 8:11 am     Reply with quote

Quote:
Will this work ??

If you have a CCS compiler, you may want to check yourself.

Are you interested in programming or just chatting?
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sat Dec 12, 2009 9:41 am     Reply with quote

Quote:

Are you interested in programming or just chatting?


I was busy working on the problem.

I tried it, it doesn't seem to work (but its possible I may be missing out something). First I want to know if the approach is right.

shift_left(in,1,!input(MMC_DI));

is correct or ...

shift_left(in,1,~input(MMC_DI));

I am trying to get an MMC card working, I am using the driver in PICC folder, mmc_spi.c.

The problem is that the MMC_DI pin is connected through a npn transistor (used for level shifting from 3.3 V to 5 V). A common emitter amplifier configuration.

So a high on MMC_DI becomes a low on the amplifier output.

I am using a 18F4620 mcu. The system works when the MMC_DI pin is directly connected to the mcu pin a5. (in this case no modification to the driver code is required).

But I would like to use the amplifier instead of a direct connection, so I thought the code could be modified to invert the MMC_DI pin states.

arunb


Last edited by arunb on Sat Dec 12, 2009 9:52 am; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 9:50 am     Reply with quote

The first is the correct syntax for one bit (logical inversion) and gives correct result with CCS C, I think. The second may work as well.
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