View previous topic :: View next topic |
Author |
Message |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Tue Nov 20, 2007 8:17 am |
|
|
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
|
|
Posted: Tue Nov 20, 2007 8:27 am |
|
|
yes i already did that and worked |
|
|
yesahycs
Joined: 31 Oct 2007 Posts: 5
|
|
Posted: Wed Dec 05, 2007 12:35 am |
|
|
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
|
|
Posted: Thu Dec 13, 2007 3:15 pm |
|
|
[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
|
|
Posted: Thu Dec 13, 2007 3:20 pm |
|
|
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
|
|
Posted: Thu Dec 13, 2007 3:58 pm |
|
|
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
|
|
Posted: Thu Dec 13, 2007 4:02 pm |
|
|
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
|
|
Posted: Thu Dec 13, 2007 4:44 pm |
|
|
What PIC type are you using for the slave and the master ?
What is your compiler version ? |
|
|
robotam
Joined: 13 Nov 2007 Posts: 15
|
|
Posted: Thu Dec 13, 2007 4:51 pm |
|
|
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
|
|
Posted: Thu Dec 13, 2007 4:59 pm |
|
|
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
|
|
Posted: Fri Dec 14, 2007 1:55 am |
|
|
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
|
|
Posted: Fri Dec 14, 2007 8:38 am |
|
|
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
|
|
Posted: Fri Dec 14, 2007 8:57 am |
|
|
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
|
I didn't get it to work either on the 1st try...more to come |
Posted: Fri Dec 14, 2007 12:44 pm |
|
|
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....! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 14, 2007 12:53 pm |
|
|
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. |
|
|
|