|
|
View previous topic :: View next topic |
Author |
Message |
lboghy
Joined: 04 Jun 2008 Posts: 23
|
I2c problem - pIC18F25k20 |
Posted: Tue Aug 16, 2011 4:26 am |
|
|
I want to use PIC18f25K20 with MCP4651 digital potentiometer.
I used the internal functions of i2c from CCS with some time ago and was OK but now is no signal on scl and sda and the micro is reseting when I want to write or read from I2c.
Code: |
#use delay(int=16000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,restart_wdt,force_hw)
if (flag_i2c) // sets at every 5 seconds
{
i2c_start();
i2c_write(0X50); // Device address
i2c_write(0X00); //Command to device
i2c_write(first_val); // Data to device
i2c_stop();
restart_wdt();
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 16, 2011 1:20 pm |
|
|
Quote: | I want to use PIC18f25K20 with MCP4651 digital potentiometer.
I used the internal functions of i2c from CCS with some time ago.
|
1. What's your CCS compiler version ?
2. What's the Vdd voltage of the PIC and the MCP4651 ?
3. Are the three address pins of the MCP4651 connected to ground ?
They need to be, to give the slave an address of 0x50.
4. Do you have 4.7K pullup resistors to Vdd on both SCL and SDA ?
5. Delete everything shown in bold below:
Quote: | #use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,restart_wdt,force_hw) |
6. Disable the Watchdog timer in your #fuses statement. Just have
NOWDT in there.
7. Run the i2c bus scanner program in the link below. Modify it for your
PIC and oscillator setup, etc. It will report any i2c slaves that the PIC
sees on the bus.
http://www.ccsinfo.com/forum/viewtopic.php?t=42368&start=4 |
|
|
|
|
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
|