<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [FRDM-KL46Z]Cannot set up proper I2C connection to MAG3110, really need help. in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487573#M30071</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jiang,&lt;/P&gt;&lt;P&gt;you have an error in your function:&lt;/P&gt;&lt;P&gt;void mag_init(){ //initialization that configures MAG3110&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG1,0x00); //standby mode&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG2,0x80); //auto reset&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG1,0x01); //active&lt;/P&gt;&lt;P&gt;} &lt;/P&gt;&lt;P&gt;It has to be as in the demo-board code:&lt;/P&gt;&lt;P&gt;void mag_init(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_init();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Initialize I2C modules&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG1,0x00); //Standby mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG2,0x80); //Auto reset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG1,0x01); //Active&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;You have not properly initialized the MAG3110 device. Please take a look on the original code in the "hal_i2c.c" file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it helps you.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Stano.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Mar 2016 12:53:06 GMT</pubDate>
    <dc:creator>Stano</dc:creator>
    <dc:date>2016-03-18T12:53:06Z</dc:date>
    <item>
      <title>[FRDM-KL46Z]Cannot set up proper I2C connection to MAG3110, really need help.</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487572#M30070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all, I am trying to implement a E-compass using the magnetometer(MAG3110) attached on KL46Z. I found a piece of example code and tried to reproduce the same function from it. However, my code doesn't work. It seems that I fail to set up a proper I2C connection to MAG3110. I can write to I2C0-&amp;gt;D, but it seems that the data doesn't go through. And when I read from I2C0-&amp;gt;D, the only value I can get is 0x1c which is actually (0x0e &amp;lt;&amp;lt; 1 | 0) (I2C address of MAG3110 or'ed with write bit). I am afraid there is no connection between the micro and MAG3110 at all.&lt;/P&gt;&lt;P&gt;I am also confused if I need to use the I2C interrupt(the example code doesn't).&amp;nbsp; I tried to disable the interrupt, but then my program got stuck in "startup_MKL46Z4.S" which probably because it could not return from interrupt. The example code clears the interrupt flag in "void I2C_wait()".&lt;/P&gt;&lt;P&gt;The attached file is the functions I use to configure the I2C connection. For simplicity other part of the code is not included. &lt;/P&gt;&lt;P&gt;Could anyone diagnose the problems for me?&amp;nbsp; Much thank!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337298"&gt;I2C_functions.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 03:44:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487572#M30070</guid>
      <dc:creator>ningzhejiang</dc:creator>
      <dc:date>2016-03-18T03:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: [FRDM-KL46Z]Cannot set up proper I2C connection to MAG3110, really need help.</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487573#M30071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jiang,&lt;/P&gt;&lt;P&gt;you have an error in your function:&lt;/P&gt;&lt;P&gt;void mag_init(){ //initialization that configures MAG3110&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG1,0x00); //standby mode&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG2,0x80); //auto reset&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_SingleByteWrite(MAG_CTRL_REG1,0x01); //active&lt;/P&gt;&lt;P&gt;} &lt;/P&gt;&lt;P&gt;It has to be as in the demo-board code:&lt;/P&gt;&lt;P&gt;void mag_init(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_init();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Initialize I2C modules&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG1,0x00); //Standby mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG2,0x80); //Auto reset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hal_dev_mag3110_write_reg(MAG_CTRL_REG1,0x01); //Active&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;You have not properly initialized the MAG3110 device. Please take a look on the original code in the "hal_i2c.c" file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it helps you.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Stano.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 12:53:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487573#M30071</guid>
      <dc:creator>Stano</dc:creator>
      <dc:date>2016-03-18T12:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: [FRDM-KL46Z]Cannot set up proper I2C connection to MAG3110, really need help.</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487574#M30072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply. But actually I did that in my main. The init function for MAG is in my main function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 14:50:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL46Z-Cannot-set-up-proper-I2C-connection-to-MAG3110-really/m-p/487574#M30072</guid>
      <dc:creator>ningzhejiang</dc:creator>
      <dc:date>2016-03-18T14:50:28Z</dc:date>
    </item>
  </channel>
</rss>

