|
|
View previous topic :: View next topic |
Author |
Message |
towerspower
Joined: 11 Jun 2017 Posts: 1
|
PIC18F2685 I2C LMP91000 |
Posted: Sun Jun 11, 2017 5:27 am |
|
|
Hello!
I'm trying to communicate the PIC18F2685 with the LMP91000 by I2C but i'm having some problems. Here it is the code i'm writting.
Code: | #use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, FAST=100000)
#define POT_SLAVE_WRT 0xD0
#define POT_SLAVE_RD 0xD1
// Register addresses
#define STATUS 0x00
#define LOCK 0x01
#define TIACN 0x10
#define REFCN 0x11
#define MODECN 0x12
void SETUP ()
{
i2c_start();
i2c_write(POT_SLAVE_WRT);
i2c_write(LOCK);
i2c_write(0x00);
i2c_stop();
i2c_start();
i2c_write(POT_SLAVE_WRT);
i2c_write(TIACN);
i2c_write(0x1F);
i2c_stop();
i2c_start();
i2c_write(POT_SLAVE_WRT);
i2c_write(REFCN);
i2c_write(0x54);
i2c_stop();
i2c_start();
i2c_write(POT_SLAVE_WRT);
i2c_write(MODECN);
i2c_write(0x03);
i2c_stop();
i2c_start();
i2c_write(POT_SLAVE_WRT);
i2c_write(LOCK);
i2c_write(0x01);
i2c_stop();
}
void main ()
{
SETUP();
while(true)
{
output_toggle(pin_A0); //this part of the code is just to know if the PIC works . It does.
delay_ms(500);
}
} |
I've already checked that i have put the pull up resistors and all the connections are okey, but i can't write on the LMP91000 registers becuse of the i2c problem. Do you have any answer to my problem? Thank you very much!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Jun 11, 2017 8:23 am |
|
|
Before doing anything else, run the I2C scanner program (in the code library), and verify that your chip is being 'seen' by your PIC at the addresses specified.
This is the first thing to do before looking at your code.
Your address does not appear to be right. The bus address of the standard 91000, is 0x90 for write, and 0x91 for read. You are using 0xD0/D1. Unless you have a non standard chip, this may be your problem.
Just checked the data sheet. Section 7.5.1. The address is 0x90/91.
Binary 10010000 for write
10010001 for read
This is almost certainly what is stopping it from working.... |
|
|
|
|
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
|