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

I2C slave transmitting data
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Tue Nov 20, 2007 8:17 am     Reply with quote

I have a suggestion to make. PIC18F2550 & 4550 have erratas in I2C master and slave. I've never been able to activate the hardware I2C master on these platforms. So i use it by software instead (on different pins too)
Have you tried your I2C mater code with an EEPROM for ex? something other than a slave micro?
Try it in order to test your master first !

Regards
robotam



Joined: 13 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Tue Nov 20, 2007 8:27 am     Reply with quote

yes i already did that and worked
yesahycs



Joined: 31 Oct 2007
Posts: 5

View user's profile Send private message

PostPosted: Wed Dec 05, 2007 12:35 am     Reply with quote

I'm interested in this topic,
robotam can u post your code that work and share on what you had changed to make it work?
Guest








PostPosted: Thu Dec 13, 2007 3:15 pm     Reply with quote

[quote="SET"][code]i2c_start();

i2c_write(0xA0);
i2c_write(0x00);
i2c_start();
i2c_write(0xA1);
data=i2c_read(0);
i2c_stop();

======================

I'm a quasi I2C newbie so put flamethrower on stun ..please! In any event, why does your 'read' call have an argument of 0? Why wouldn't you just use
data=i2c_read(); instead of i2c_read(0); ?
robotam



Joined: 13 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 3:20 pm     Reply with quote

SET wrote:

i2c_start();

i2c_write(0xA0);
i2c_write(0x00);
i2c_start();
i2c_write(0xA1);
data=i2c_read(0);
i2c_stop();

======================

I'm a quasi I2C newbie so put flamethrower on stun ..please! In any event, why does your 'read' call have an argument of 0? Why wouldn't you just use
data=i2c_read(); instead of i2c_read(0); ?


Hello,

I just followed an exemple from Pcprogrammer, My Master send data
correctly to the slave but i can't read from the slave.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 3:58 pm     Reply with quote

1. Use the CCS example code for the Slave.
2. Use the hardware i2c pins (SDA and SCL) on the Slave PIC.
3. Run the Slave PIC at 20 MHz.
4. Make sure you have a ground connection between the Master
and Slave boards.
5. Make sure you have pull-up resistors on the SDA and SCL signals.
robotam



Joined: 13 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 4:02 pm     Reply with quote

PCM programmer wrote:
1. Use the CCS example code for the Slave.
2. Use the hardware i2c pins (SDA and SCL) on the Slave PIC.
3. Run the Slave PIC at 20 MHz.
4. Make sure you have a ground connection between the Master
and Slave boards.
5. Make sure you have pull-up resistors on the SDA and SCL signals.


Thank you PCM Programmer for responding,

I checked everything, but i can't receive data from the slave.

Regards.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 4:44 pm     Reply with quote

What PIC type are you using for the slave and the master ?

What is your compiler version ?
robotam



Joined: 13 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 4:51 pm     Reply with quote

PCM programmer wrote:
What PIC type are you using for the slave and the master ?

What is your compiler version ?


Master 18F2550
Slave DSpic 30f4012

pcwhd 4.057
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 13, 2007 4:59 pm     Reply with quote

Quote:

Master 18F2550
Slave DSpic 30f4012

pcwhd 4.057

Try using an 18F-series PIC for the Slave, instead of the dsPIC.
(Keep the 18F2550 for the Master).
robotam



Joined: 13 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Fri Dec 14, 2007 1:55 am     Reply with quote

PCM programmer wrote:
Quote:

Master 18F2550
Slave DSpic 30f4012

pcwhd 4.057

Try using an 18F-series PIC for the Slave, instead of the dsPIC.
(Keep the 18F2550 for the Master).


i need to control a motor with dspic
Guest








PostPosted: Fri Dec 14, 2007 8:38 am     Reply with quote

PCM programmer wrote:
Quote:

Master 18F2550
Slave DSpic 30f4012

pcwhd 4.057

Try using an 18F-series PIC for the Slave, instead of the dsPIC.
(Keep the 18F2550 for the Master).


That means I2C doesn't work with DSPIC ???????!!!!!!!!!!!!!!
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Dec 14, 2007 8:57 am     Reply with quote

Not so much that the DsPIC I2C wont work, just to work out if your setup is correct - 18F's at both ends are a 'better bet' than 18F to DsPIC
PICdawg



Joined: 13 Dec 2007
Posts: 17

View user's profile Send private message

I didn't get it to work either on the 1st try...more to come
PostPosted: Fri Dec 14, 2007 12:44 pm     Reply with quote

Robotam

I tried to make this work last night using 2 16f876a's, one as master, one as slave, using the MSSP hardware. I used the Ex_slave.c in the slave. I had no trouble writing to slave successfully. I couldn't read back from the slave either. I'm using the ICD2 and the master program is 'hanging' on the I2c stop line. I have used I2c with an 876a as the master for a couple other projects, but only to write(not read) More to come...

I have a number of additional tests I'm going to try including looking at the I2C lines with a scope/logic analyzer and see if the slave is writing back or not. Also will try setting up the master and slave without using the MSSP hardware. I will run a couple tests with the master writing and reading(hopefully) to/from an 8574 chip(i2c to parallel 8 bit converter). Finally, I'm going to try a different master and slave example out of the book "Embedded C Programming and the Microchip PIC". It uses the I2c_poll function.

I'll keep you posted. I need to get this working for my current PIC project, so I have some 'skin' in this game also....! Surprised
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 14, 2007 12:53 pm     Reply with quote

Quote:
Also will try setting up the master and slave without using the MSSP hardware.

The slave must use the hardware i2c module. CCS has no library code
that creates a software i2c slave. You must use the hardware SDA
and SCL pins for the slave.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
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