|
|
View previous topic :: View next topic |
Author |
Message |
korghs
Joined: 26 Aug 2011 Posts: 3
|
PIC24HJ (12GP202) and I2C |
Posted: Fri Aug 26, 2011 11:45 am |
|
|
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
|
|
Posted: Fri Aug 26, 2011 2:21 pm |
|
|
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
|
|
Posted: Fri Aug 26, 2011 2:47 pm |
|
|
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
|
|
Posted: Sat Aug 27, 2011 3:43 am |
|
|
Interesting,
got down to
Code: | #use i2c(master, sda=pin_b9, scl=pin_b8, slow, force_hw) |
Seems to work, too |
|
|
|
|
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
|