MikroC pro pic32 I2C Question

General discussion on Visual TFT Software.
Post Reply
Author
Message
sprbok
Posts: 11
Joined: 30 Aug 2011 21:13

MikroC pro pic32 I2C Question

#1 Post by sprbok » 23 Apr 2014 23:32

I am trying to read from a device using I2C with a write address of 14H and a read address of 15h and a command of 4C
I am not sure if if MikroC pro for pic32 automatically adds the write and read bit.
Is this How i should write it?
I2C2_Start(); // issue I2C start signal
I2C2_Write(0x14); // send byte via I2C (device address + W)
I2C2_Write(4C); // send byte (data address)
I2C2_Restart(); // issue I2C signal repeated start
I2C2_Write(0x15); // send byte (device address + R)
reslt = I2C2_Read(1); // Read the data (NO acknowledge)
I2C2_Stop();

Or like this
I2C2_Start(); // issue I2C start signal
I2C2_Write(0x0A); // send byte via I2C (device address - W bit)
I2C2_Write(4C); // send byte (data address) xxxxx NOT SURE IF IT SHOULD BE 26h xxxxxx
I2C2_Restart(); // issue I2C signal repeated start
I2C2_Write(0x0A); // send byte (device address - R bit)
reslt = I2C2_Read(1); // Read the data (NO acknowledge)
I2C2_Stop();

Thanks!!
Last edited by sprbok on 24 Apr 2014 04:49, edited 1 time in total.

bpislife
Posts: 539
Joined: 11 Jun 2006 21:16
Location: Cumberland, RI

Re: MikroC pro pic32 I2C Question

#2 Post by bpislife » 24 Apr 2014 02:42

The top example is correct.

sprbok
Posts: 11
Joined: 30 Aug 2011 21:13

Re: MikroC pro pic32 I2C Question

#3 Post by sprbok » 24 Apr 2014 04:48

Thank you!!

Post Reply

Return to “Visual TFT General”