urgent help on pic16ka102 and mag3110 using i2c

11 views
Skip to first unread message

T Obulesu

unread,
Jul 1, 2018, 9:37:19 AM7/1/18
to PIC24 Assembly-to-C Book
Hi..
Can some one please help me on writing the i2c code just to read the mag3110 sensor data using the pic24f16ka102?

I struggled a lot to implement my own i2c library for the fxos8700cq and somehow i got it work. And I don't want to use all the functions in I2C (Except i2c init, read, write, start, stop).
But the same library is not working for the mag3110 and am in desperate need of it.

So please help me on at least reading the WHO_AM_I register of the mag3110 sensor using pic24f16ka102 and how to set the active and idel mode of the sensor?

Jones, Bryan

unread,
Jul 1, 2018, 10:07:05 AM7/1/18
to pic24-assemb...@googlegroups.com
I would guess something like

startI2C1();
// Write the register to be read. A 7-bit address of 0x0E == 0b0000 1110 as 8 bits, or 0b0001 110 as seven bits. Adding a 0 to the bottom for a write gives 0b0001 1100 = 0x1C.
putI2C1(0x1C);

// The WHO_AM_I register
putI2C1(0x07);
// Switch to a read
rstartI2C1();
putI2C1(0x1D);
// Get the register data; just one read.
u8_who_am_i = getI2C1(1);
stopI2C1();

Beyond that, it's up to you.

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.
To post to this group, send email to pic24-assemb...@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.


--
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi State, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

T Obulesu

unread,
Jul 2, 2018, 8:11:53 AM7/2/18
to PIC24 Assembly-to-C Book
Hi..
Thanks for your swift response..
These steps are fine .. But I want to implement my own I2C in a simplest way...
I tried a lot using the available libraries but does not give me any subject..
startI2C1();..
 what is the internal implementation of this for pic24f16ka102 which is so irritating?


Should I use the interrupt for identifying whether the slave data/ack is received or not..etc...


On Sunday, 1 July 2018 19:37:05 UTC+5:30, Bryan A. Jones wrote:
I would guess something like

startI2C1();
// Write the register to be read. A 7-bit address of 0x0E == 0b0000 1110 as 8 bits, or 0b0001 110 as seven bits. Adding a 0 to the bottom for a write gives 0b0001 1100 = 0x1C.
putI2C1(0x1C);

// The WHO_AM_I register
putI2C1(0x07);
// Switch to a read
rstartI2C1();
putI2C1(0x1D);
// Get the register data; just one read.
u8_who_am_i = getI2C1(1);
stopI2C1();

Beyond that, it's up to you.

On Sun, Jul 1, 2018 at 8:37 AM T Obulesu <obul...@gmail.com> wrote:
Hi..
Can some one please help me on writing the i2c code just to read the mag3110 sensor data using the pic24f16ka102?

I struggled a lot to implement my own i2c library for the fxos8700cq and somehow i got it work. And I don't want to use all the functions in I2C (Except i2c init, read, write, start, stop).
But the same library is not working for the mag3110 and am in desperate need of it.

So please help me on at least reading the WHO_AM_I register of the mag3110 sensor using pic24f16ka102 and how to set the active and idel mode of the sensor?

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.

Jones, Bryan

unread,
Jul 2, 2018, 8:41:15 AM7/2/18
to pic24-assemb...@googlegroups.com

On Mon, Jul 2, 2018 at 7:11 AM T Obulesu <obul...@gmail.com> wrote:
Hi..
Thanks for your swift response..
These steps are fine .. But I want to implement my own I2C in a simplest way...
I tried a lot using the available libraries but does not give me any subject..
startI2C1();..
 what is the internal implementation of this for pic24f16ka102 which is so irritating?


Should I use the interrupt for identifying whether the slave data/ack is received or not..etc...


On Sunday, 1 July 2018 19:37:05 UTC+5:30, Bryan A. Jones wrote:
I would guess something like

startI2C1();
// Write the register to be read. A 7-bit address of 0x0E == 0b0000 1110 as 8 bits, or 0b0001 110 as seven bits. Adding a 0 to the bottom for a write gives 0b0001 1100 = 0x1C.
putI2C1(0x1C);

// The WHO_AM_I register
putI2C1(0x07);
// Switch to a read
rstartI2C1();
putI2C1(0x1D);
// Get the register data; just one read.
u8_who_am_i = getI2C1(1);
stopI2C1();

Beyond that, it's up to you.

On Sun, Jul 1, 2018 at 8:37 AM T Obulesu <obul...@gmail.com> wrote:
Hi..
Can some one please help me on writing the i2c code just to read the mag3110 sensor data using the pic24f16ka102?

I struggled a lot to implement my own i2c library for the fxos8700cq and somehow i got it work. And I don't want to use all the functions in I2C (Except i2c init, read, write, start, stop).
But the same library is not working for the mag3110 and am in desperate need of it.

So please help me on at least reading the WHO_AM_I register of the mag3110 sensor using pic24f16ka102 and how to set the active and idel mode of the sensor?

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.

T Obulesu

unread,
Jul 2, 2018, 10:12:51 AM7/2/18
to PIC24 Assembly-to-C Book
Thanks a lot Sir,
This is very helpful..
It exactly explaina what registers I have to use and what is the purpose of in a very structured way...

I'm even trying the below link which is further simpler..
I'm even looking for more information like what exactly happens when the start condition is initiated... I mean how triggering the start bit is going to give me the pulse..

I don't know how far it is correct to use the below link
http://www.robot-electronics.co.uk/i2c-tutorial

Jones, Bryan

unread,
Jul 5, 2018, 9:56:44 AM7/5/18
to pic24-assemb...@googlegroups.com
The PIC24 reference manuals are where I'd look.


--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.
To post to this group, send email to pic24-assemb...@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages