View previous topic :: View next topic |
Author |
Message |
jemmyduc
Joined: 22 May 2013 Posts: 18
|
using pin RD2 and RD3 I2C of 18F4431 in slave mode |
Posted: Sun Dec 29, 2013 12:28 pm |
|
|
I use the SDA and SCL pins of the SSP module of PIC18F4431 multiplexed with the RD2 and RD3 pins to use it for I2C bus. But the i2c could not work.
I find in the forum and so show that it is the bug of the compiler.
Could you have the solution to help me to fix this?
I'm using the version 4.114 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Dec 29, 2013 1:19 pm |
|
|
If you use the right syntax, it does work. The problem is that the compiler doesn't 'know' that pins D2&D3 are the I2C.
Way round it is to program the I2C, with:
#use i2c(SLAVE,I2C1,Address=xx)
This tells the compiler to use the hardware I2C1 device, which it happily then does.
Add the fuse:
SSP_RD
which then connects the I2C1 device to D2/D3.
Make sure the TRIS on D2, and D3 is set to 1 (by default it is unless you change it). Output_float(PIN_D2); and output_float(PIN_D3);
Best Wishes |
|
|
jemmyduc
Joined: 22 May 2013 Posts: 18
|
|
Posted: Sun Dec 29, 2013 9:17 pm |
|
|
I had a good I2C performance. Thank for your help. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Dec 30, 2013 1:18 am |
|
|
Good.
It is one of those "pity they didn't document how to do it" things.
Have a good New Year. |
|
|
jemmyduc
Joined: 22 May 2013 Posts: 18
|
|
Posted: Mon Dec 30, 2013 10:21 pm |
|
|
Thank you again. |
|
|
|