View previous topic :: View next topic |
Author |
Message |
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
DSPIC33 I2C Streams |
Posted: Thu May 11, 2017 10:43 am |
|
|
From what I understand, the DSPIC33 has multiple I2C interfaces. The problem is, I can only get one to work.
Using
Code: | #use I2C( MASTER, I2C2 ) |
and commands like
my clock works, but using
Quote: | #use I2C( STREAM=RTC, MASTER, I2C2 ) |
and commands like
causes the data returned to always be 0.
I have attempted using pin_select
Quote: | #pin_select SCL2OUT = PIN_F5 // Invalid Pin ID
#pin_select SCL2IN = PIN_F5
#pin_select SDA2OUT = PIN_F4
#pin_select SDA2IN = PIN_F4 |
but this and other variations will not compile.
I am not asking how to read a clock. The clock works fine with a single I2C. What I need to know is what I am missing to be able to use both I2C1 and I2C2 at the same time. |
|
|
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Thu May 11, 2017 11:05 am |
|
|
Got it, maybe.
Seems for this I need to use FORCE_SW
Any additional input is still welcome.
Last edited by Ranfo on Thu May 11, 2017 11:13 am; edited 1 time in total |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu May 11, 2017 11:12 am |
|
|
Post your PIC and CCS version.
You are currently using software based I2C and not hardware.
Regards |
|
|
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Thu May 11, 2017 11:15 am |
|
|
DSPIC33EP512MC806
PCWHD 5.071 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Thu May 11, 2017 3:31 pm |
|
|
Your chip does not have the I2C as a re-mappable peripheral. I2C2, is on pins RF4 and RF5. Fixed. This is why you can't use #PIN SELECT.
The I2C1 peripheral is moveable using the fuses. ALTI2C1 or NOALTI2C1. Your chip doesn't offer the ALTI2C2 fuse.
Your:
use I2C( MASTER, I2C2 )
Should work, but you need to specify the speed. It defaults to 'as fast as possible', which may well be too fast for the device you are talking to, or the pullups you have. Remember that pullups need to generate the required current and on low voltage devices this means smaller pullups for a given speed. Something like 1K8, is great for most 3.3v devices.
Also beware to ensure everything else on the pins that might interfere is turned off. The parallel master port has priority on those pins over the I2C. Need to ensure this is disabled. |
|
|
|