Page 1 of 1

I2C

Posted: Sun Jan 13, 2008 12:25 pm
by andy20989
Hey Guys,

I am workig on my final year project at university, and i'm building an autonomous robot.

I am using a PIC 18F4455, an I2C H-Bridge Motor Driver, and an LCD obviously along with other components and bits and bobs.

I'm using a professional version of Flowcode and i'm having a few issues which i'm not sure about.

First of all: My I2C device has an address of 0xB0 and I need to write to registers within it to power the motors- for example to power motor 1 I need to write to address '0' and I want to write a value of 140 to it- how do I go about doing this? Can you guys provide me with some example of I2C 'write to' code please?

Second of all: My LCD will not work, and I really dont know why- I'm using an LCD with a built in KS0066U. I need to connect RS R/W E and the Data Lines.... Flowcode specifies RS and E- but what do I connect R/W to? I've been using a version 2 development board, and I can make the built in LCD work on there either; I think flowcode might be allergic to me :?

Any ideas to help me out please guys?

Many Thanks,


Andy

Posted: Sun Jan 13, 2008 3:47 pm
by Benj
Hello Andy

Regarding the I2C question. The standard way to write to an I2C register is to do the following. You may have to refer to the device datasheet to verify this.

Start the I2C transaction
Send out a byte for the hardware address and write mode (0xB0).
Send out a byte for the internal address (0x00).
Send out the value to be assigned to the register (140).
Stop the I2C transaction.

Regarding your LCD problems. Here are a few things you can try. In Flowcode make sure that the clock speed setting matches the crystal you are using. Then in the chip configuration menu go into the expert settings and set the Oscillator to HS if XTAL > 4MHz otherwise XT. Also disable the watchdog timer and the low voltage programming. The R/W pin can be connected directly to ground as you will only really ever want to write to the LCD.