|
|
View previous topic :: View next topic |
Author |
Message |
chandra
Joined: 19 Mar 2010 Posts: 18
|
PIC12F629 and I2C for MC44BS374T1AEF |
Posted: Thu Aug 04, 2011 8:28 am |
|
|
Hi,
This is the code:
Code: |
#include <12F629.h>
#fuses XT,NOWDT,NOPROTECT,NOMCLR,PUT,NOBROWNOUT
#use delay(clock=4000000)
#use i2c(Master, sda=PIN_A0, scl=PIN_A1)
#define SLAVE_WRT_ADDR 0xCA
#define SLAVE_READ_ADDR 0xCB
void main() {
delay_ms(50);
while(TRUE)
{
i2c_start();
i2c_write(SLAVE_WRT_ADDR);
i2c_write(0x80);
i2c_write(0x08);
i2c_write(0x1E);
i2c_write(0x94);
i2c_stop();
while(TRUE);
}
}
|
I am using pull up resistors 3.3k. And the oscilloscope is showing the clock and data pulses clearly. But the chip is not getting on. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 04, 2011 12:49 pm |
|
|
Quote: |
#use i2c(Master, sda=PIN_A0, scl=PIN_A1)
|
I notice that pins A0 and A1 are also used by the programmer
(ICD2, ICD3, ICD-U40, ICD-U64, Pickit 2, Pickit 3, etc.).
Is your programmer connected to pins A0 and A1 while you're
trying to talk to the i2c slave device ? I think you should disconnect
the programmer.
Here is a program which can detect if the i2c slave device is available
on the i2c bus. This test will tell you if you the slave chip is actually
at the 0xCA i2c address, or if it can't be found at all.
http://www.ccsinfo.com/forum/viewtopic.php?t=37650&start=6
This program requires an rs232 connection between the 12F675 and
the PC. You appear to have pin A2 as a spare pin, so you could use that.
Also, most people would use the internal oscillator on this PIC if at all
possible, because it frees up 2 i/o pins if you do that. Here is the
PIC setup for this:
Code: |
#include <12F675.h>
#fuses INTRC_IO, NOWDT, NOMCLR, PUT, BROWNOUT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A2, INVERT)
|
You would connect pin A2 on the PIC to pin 2 (Rxd) on the Com1
connector on your PC. You also need a ground wire between the PIC
board and pin 5 of the Com1 connector. Then you have to install
TeraTerm or some other suitable serial terminal program. Then you
can send diagnostic messages to the PC from the PIC with a printf()
statement, as shown in the program given in the link above. |
|
|
|
|
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
|