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

PIC24HJ (12GP202) and I2C

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



Joined: 26 Aug 2011
Posts: 3

View user's profile Send private message

PIC24HJ (12GP202) and I2C
PostPosted: Fri Aug 26, 2011 11:45 am     Reply with quote

Hi there,


I'm quite new to this Compiler and the PIC24HJ12GP202 and I'm actually stuck at the most stupid point, right at the beginning!

The aim is to simply communicate by I²C


Code:

#include <24HJ12GP202.h>
#use delay(clock=4000000)
#use i2c(i2c1,Master,Slow,force_hw)

void main()
{

    output_high(pin_b15);

while (1)
{
    output_high(pin_b14);
    i2c_start();
    delay_ms(50);
    i2c_write(0xAA);
    delay_ms(50);
    i2c_stop();
    output_low(pin_b14);
    delay_ms(100);

}
}


Watching each pin used, with an oscilloscope, b15 sticks to high, b14 jumps as wanted, but I've got absolutely no signal on b9(18/SDA1) or b8(17/SCL1).

Have I missed anything in the datasheet/ccs c docs?


Thanks!

P.S.

I'm currently running the limited eval of 4.122d.
korghs



Joined: 26 Aug 2011
Posts: 3

View user's profile Send private message

PostPosted: Fri Aug 26, 2011 2:21 pm     Reply with quote

Code:
#use i2c(master, sda=pin_b9, scl=pin_b8)


seems to be the easiest way to solve my problem.


Also played around with the pull-ups on sda and scl, got both down to 1.8k.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 26, 2011 2:47 pm     Reply with quote

Quote:
#use i2c(i2c1,Master,Slow,force_hw)

It's entirely possible that 'i2c1' and/or 'force_hw' uses the wrong pins or
the wrong registers in your version of the compiler. Using software i2c, as
you found, has a much better chance to work.
korghs



Joined: 26 Aug 2011
Posts: 3

View user's profile Send private message

PostPosted: Sat Aug 27, 2011 3:43 am     Reply with quote

Interesting,

got down to

Code:
#use i2c(master, sda=pin_b9, scl=pin_b8, slow, force_hw)


Seems to work, too
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