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

DSPIC33 I2C Streams

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



Joined: 08 Sep 2008
Posts: 38

View user's profile Send private message

DSPIC33 I2C Streams
PostPosted: Thu May 11, 2017 10:43 am     Reply with quote

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
Code:
i2c_start();

my clock works, but using
Quote:
#use I2C( STREAM=RTC, MASTER, I2C2 )

and commands like
Quote:
i2c_start(RTC);

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

View user's profile Send private message

PostPosted: Thu May 11, 2017 11:05 am     Reply with quote

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: 349
Location: South Africa

View user's profile Send private message

PostPosted: Thu May 11, 2017 11:12 am     Reply with quote

Post your PIC and CCS version.

You are currently using software based I2C and not hardware.

Regards
Ranfo



Joined: 08 Sep 2008
Posts: 38

View user's profile Send private message

PostPosted: Thu May 11, 2017 11:15 am     Reply with quote

DSPIC33EP512MC806
PCWHD 5.071
Ttelmah



Joined: 11 Mar 2010
Posts: 19221

View user's profile Send private message

PostPosted: Thu May 11, 2017 3:31 pm     Reply with quote

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.
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