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

ask for help

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



Joined: 29 Jul 2007
Posts: 31
Location: UK

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

ask for help
PostPosted: Fri Aug 17, 2007 11:28 am     Reply with quote

Dear all,
after building RS232 interface in my LCD module, I wanna build I2C and SPI interfaces into it as well, is there any friend who can give me the suggestion about the code for those two interfaces.
As the codes I writing for I2C and SPI:

Code:
#USE RS232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)
#USE I2C(slave, sda=PIN_C4, scl=PIN_C3, address=0xA0)
...
while(1)
{
   while(!i2c_poll());
   lcd_putc("\f I2C data: \n");
   value3=i2c_read();
   lcd_putc(value3);
}                //end while of I2C

while(1)
{
output_low(PIN_A5);
while(!spi_data_is_in() && input(PIN_A5));
if (spi_data_is_in())
value3=spi_read();
lcd_putc(value3);
}                 //end while of SPI



But it seems not work well. My LCD module would be treated as a slave mode, just being used to receive data from other hardware.

Thanks for your help indeed.
_________________
Enjoy our EEE
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 11:45 am     Reply with quote

You should stop posting questions in the Code Library. Post them
only in this forum (The General Discussion forum). On the main forum
index page, Darren has posted a warning about this:
Quote:

Code Library
Post and share your WORKING libraries and examples for other users
to use. This is -NOT- the forum to be asking for help.


Also, don't do double posts. Don't post the same thing two or more times.

Here is the link for the main CCS forum (the one you're in now).
Bookmark this link, and delete the link that you have to the Code Library.
http://www.ccsinfo.com/forum/viewforum.php?f=1
applecon2000



Joined: 29 Jul 2007
Posts: 31
Location: UK

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

dear sir
PostPosted: Fri Aug 17, 2007 5:35 pm     Reply with quote

As a frashman using this system, I am not really familar with your rules.
Sorry to bring you so many troubles.
_________________
Enjoy our EEE
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 6:04 pm     Reply with quote

I don't understand your question. Do you want to connect all of RS232, SPI and I2C at the same time?

For an I2C master the functions can be emulated by software but for a slave you always have to select the SSP hardware unit of the PIC.

The i2c_poll() function only works in combination with the SSP hardware unit. By default the #use I2C directive generates a software I2C driver. Change to
Code:
#USE I2C(slave, sda=PIN_C4, scl=PIN_C3, address=0xA0, FORCE_HW)


In your SPI code you have:
Code:
output_low(PIN_A5);
while(!spi_data_is_in() && input(PIN_A5));
How is your hardware connected? Now you are using PIN_A5 for both input _and_ output. This looks like a bug.

Where is your setup_spi() call?
applecon2000



Joined: 29 Jul 2007
Posts: 31
Location: UK

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

Thanks first but......
PostPosted: Fri Aug 17, 2007 6:35 pm     Reply with quote

My project was to use PIC16F876 to drive a 16x2 LCD module. SPI and I2C were two interfaces needed to build in it.
As treating my LCD module as a slave item, I wanna simulate my design in ISIS, my RS232 was working well, but I can't simulate those two successfully.
For SPI PIN_A5 being a Selecting signal with the low level to startup data transmitting.

Could you please show me one simple program which driving SPI and I2C working in microchip?

I am so glad to receive your reply, anyway, sorry to bring you so many troubles, what I can do now just give you my acknowledgement.
Best regards.
_________________
Enjoy our EEE
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