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

SPI AND I2C AND RS232 all together?

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



Joined: 27 May 2004
Posts: 12
Location: Austria

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

SPI AND I2C AND RS232 all together?
PostPosted: Tue Feb 19, 2008 3:09 am     Reply with quote

Hello,

I would like to have on a PIC16F73:
1.) RS232 AND
2.) either (determined by a pin on start-up): SPI OR I2C

unluckily CCS (3.227) uses difference setup processes for these interfaces (#USE_RS232, #USE_I2C, setup_spi).

my fear is, and i think i had troubles with it once, that #USE_I2C will remain permanently in the program code and i can not completely overrule it with setup_spi (if determined by a pin on start-up).

Am i right?
Any work around?

thank you! Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 12:56 pm     Reply with quote

If you have a #use i2c() statement, and you're using hardware i2c,
the compiler will put in code at the start of main() to setup the MSSP
module for i2c. It will setup the SSPCON and SSPSTAT registers, and
it will also setup the TRIS for pins C3 and C4. You can see this code
if you look at the .LST file.

If you have a setup_spi() statement in main(), it will execute after
the start-up code for the i2c, and it will overwrite the values in SSPCON
and SSPSTAT. It will configure those registers for SPI mode.
It will also set the TRIS for pins C3 and C4.
YUM



Joined: 27 May 2004
Posts: 12
Location: Austria

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

... in reply
PostPosted: Wed Feb 20, 2008 12:56 am     Reply with quote

Hello and thanks for this first answer,

but it leads me to other questions:

1.)
why does CCS use different methods (#USE..., setup_....) to setup modules?
wouldn't it be nicer to have all of them as setup..., so i can use them in conditional statements?
(if ("pin is high") --> setup_spi)
(if ("pin is low") --> setup_i2c)

2.)
are the setups (any of the two possibilities) doing anything else, except setting 2 or 3 registers?
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