<?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 KL25Z i2C LCD module configuration in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1556743#M64327</link>
    <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;Im using a KL25Z and having tons of trouble for the past 2 weeks getting a LCD screen to initialize using I2C. Ive asked about it on reddit and Ive just been told the reason people use arduino is because its open source and these things are so **bleep** finicky. I guess i was hoping the community here can help.&lt;/P&gt;&lt;P&gt;I have this screen&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.amazon.ca/gp/product/B019K5X53O/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&amp;amp;psc=1" target="_blank"&gt;https://www.amazon.ca/gp/product/B019K5X53O/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&amp;amp;psc=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Default write address is 0x4E&lt;/P&gt;&lt;P&gt;This is board manual&lt;/P&gt;&lt;P&gt;&lt;A href="https://spivey.oriel.ox.ac.uk/dswiki/images-digisys/5/56/KL25-refman.pdf" target="_blank"&gt;https://spivey.oriel.ox.ac.uk/dswiki/images-digisys/5/56/KL25-refman.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Im trying to use port E pins 1 and 0.&lt;/P&gt;&lt;P&gt;Ive tried using external 3.8k and 1k pull up resistors on sda and scl.&lt;/P&gt;&lt;P&gt;Any insight is of help, this is making me just want to use arduinos aha but i must prevail and learn.&lt;/P&gt;&lt;P&gt;Screen just stays light with top row as blocks.&lt;/P&gt;&lt;P&gt;My code as its called is as follows&lt;/P&gt;&lt;P&gt;int main (void) {&lt;BR /&gt;&lt;BR /&gt;i2c_init();&amp;nbsp; // enable I2C&lt;BR /&gt;Delay(10);&lt;BR /&gt;init_I2C_LCD(); // enable screen&lt;BR /&gt;// Print_LCD("Hello, World!"); // print, commented out since doesn't seem to communicate properly.&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;void i2c_init(void)&lt;BR /&gt;{&lt;BR /&gt;//clock i2c peripheral and port E&lt;BR /&gt;SIM-&amp;gt;SCGC4 |= SIM_SCGC4_I2C1_MASK;&lt;BR /&gt;SIM-&amp;gt;SCGC5 |= (SIM_SCGC5_PORTE_MASK);&lt;BR /&gt;//set pins to I2C function&lt;BR /&gt;PORTE-&amp;gt;PCR[0] |= PORT_PCR_MUX(6);&lt;BR /&gt;PORTE-&amp;gt;PCR[1] |= PORT_PCR_MUX(6);&lt;/P&gt;&lt;P&gt;//set to 100k baud&lt;BR /&gt;//baud = bus freq/(scl_div*mul)&lt;BR /&gt;//100k = 24M/(1*240); icr=0x1F sets scl_div to 240&lt;BR /&gt;I2C1-&amp;gt;F = (I2C_F_ICR(0x1F) | I2C_F_MULT(0));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//enable i2c and interrupts&lt;BR /&gt;I2C1-&amp;gt;C1 = 0x00; // preemptive clearing for trouble shooting, didnt fix anything&lt;BR /&gt;I2C1-&amp;gt;C1 |= (I2C_C1_IICEN_MASK | I2C_C1_IICIE_MASK); // enable&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void init_I2C_LCD(void)&lt;BR /&gt;{&lt;BR /&gt;// Delay(100);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;Delay(100);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;Delay(10);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;LCD_Write_4bit_CMD(0x2); // set to 4 bit&lt;BR /&gt;LCD_Write_8bit_CMD(0x28); // set 2 lines&lt;BR /&gt;LCD_Write_8bit_CMD(0x0C); //&lt;BR /&gt;LCD_Write_8bit_CMD(0x06);&lt;BR /&gt;LCD_Write_8bit_CMD(0x80);&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void LCD_Write_4bit_CMD(uint8_t c)&lt;BR /&gt;{&lt;BR /&gt;// input must be in form of 0x0c or 0xc&lt;BR /&gt;// For instructions RS &amp;amp; RW =0&lt;BR /&gt;uint8_t EHi = 0x04;&lt;BR /&gt;uint8_t ELo = 0x00;&lt;BR /&gt;&lt;BR /&gt;I2C_TRAN;&lt;BR /&gt;I2C_M_START;&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;BR /&gt;I2C1-&amp;gt;D = LCD_ADDR_W;&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C1-&amp;gt;D = ((c&amp;lt;&amp;lt;4) | ELo);&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C1-&amp;gt;D = ((c&amp;lt;&amp;lt;4) | EHi);&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C_M_STOP;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define I2C_TRAN I2C1-&amp;gt;C1 |= I2C_C1_TX_MASK&lt;/P&gt;&lt;P&gt;#define I2C_M_START I2C1-&amp;gt;C1 |= I2C_C1_MST_MASK&lt;BR /&gt;#define I2C_M_STOP I2C1-&amp;gt;C1 &amp;amp;= ~I2C_C1_MST_MASK&lt;/P&gt;&lt;P&gt;#define I2C_WAIT while((I2C1-&amp;gt;S &amp;amp; I2C_S_IICIF_MASK)==0) {} \&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;#define LCD_ADDR_W 0x4E&lt;/P&gt;</description>
    <pubDate>Sun, 20 Nov 2022 18:04:52 GMT</pubDate>
    <dc:creator>galenmoir</dc:creator>
    <dc:date>2022-11-20T18:04:52Z</dc:date>
    <item>
      <title>KL25Z i2C LCD module configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1556743#M64327</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;Im using a KL25Z and having tons of trouble for the past 2 weeks getting a LCD screen to initialize using I2C. Ive asked about it on reddit and Ive just been told the reason people use arduino is because its open source and these things are so **bleep** finicky. I guess i was hoping the community here can help.&lt;/P&gt;&lt;P&gt;I have this screen&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.amazon.ca/gp/product/B019K5X53O/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&amp;amp;psc=1" target="_blank"&gt;https://www.amazon.ca/gp/product/B019K5X53O/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&amp;amp;psc=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Default write address is 0x4E&lt;/P&gt;&lt;P&gt;This is board manual&lt;/P&gt;&lt;P&gt;&lt;A href="https://spivey.oriel.ox.ac.uk/dswiki/images-digisys/5/56/KL25-refman.pdf" target="_blank"&gt;https://spivey.oriel.ox.ac.uk/dswiki/images-digisys/5/56/KL25-refman.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Im trying to use port E pins 1 and 0.&lt;/P&gt;&lt;P&gt;Ive tried using external 3.8k and 1k pull up resistors on sda and scl.&lt;/P&gt;&lt;P&gt;Any insight is of help, this is making me just want to use arduinos aha but i must prevail and learn.&lt;/P&gt;&lt;P&gt;Screen just stays light with top row as blocks.&lt;/P&gt;&lt;P&gt;My code as its called is as follows&lt;/P&gt;&lt;P&gt;int main (void) {&lt;BR /&gt;&lt;BR /&gt;i2c_init();&amp;nbsp; // enable I2C&lt;BR /&gt;Delay(10);&lt;BR /&gt;init_I2C_LCD(); // enable screen&lt;BR /&gt;// Print_LCD("Hello, World!"); // print, commented out since doesn't seem to communicate properly.&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;void i2c_init(void)&lt;BR /&gt;{&lt;BR /&gt;//clock i2c peripheral and port E&lt;BR /&gt;SIM-&amp;gt;SCGC4 |= SIM_SCGC4_I2C1_MASK;&lt;BR /&gt;SIM-&amp;gt;SCGC5 |= (SIM_SCGC5_PORTE_MASK);&lt;BR /&gt;//set pins to I2C function&lt;BR /&gt;PORTE-&amp;gt;PCR[0] |= PORT_PCR_MUX(6);&lt;BR /&gt;PORTE-&amp;gt;PCR[1] |= PORT_PCR_MUX(6);&lt;/P&gt;&lt;P&gt;//set to 100k baud&lt;BR /&gt;//baud = bus freq/(scl_div*mul)&lt;BR /&gt;//100k = 24M/(1*240); icr=0x1F sets scl_div to 240&lt;BR /&gt;I2C1-&amp;gt;F = (I2C_F_ICR(0x1F) | I2C_F_MULT(0));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//enable i2c and interrupts&lt;BR /&gt;I2C1-&amp;gt;C1 = 0x00; // preemptive clearing for trouble shooting, didnt fix anything&lt;BR /&gt;I2C1-&amp;gt;C1 |= (I2C_C1_IICEN_MASK | I2C_C1_IICIE_MASK); // enable&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void init_I2C_LCD(void)&lt;BR /&gt;{&lt;BR /&gt;// Delay(100);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;Delay(100);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;Delay(10);&lt;BR /&gt;LCD_Write_4bit_CMD(0x3); // set 8 bit&lt;BR /&gt;LCD_Write_4bit_CMD(0x2); // set to 4 bit&lt;BR /&gt;LCD_Write_8bit_CMD(0x28); // set 2 lines&lt;BR /&gt;LCD_Write_8bit_CMD(0x0C); //&lt;BR /&gt;LCD_Write_8bit_CMD(0x06);&lt;BR /&gt;LCD_Write_8bit_CMD(0x80);&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void LCD_Write_4bit_CMD(uint8_t c)&lt;BR /&gt;{&lt;BR /&gt;// input must be in form of 0x0c or 0xc&lt;BR /&gt;// For instructions RS &amp;amp; RW =0&lt;BR /&gt;uint8_t EHi = 0x04;&lt;BR /&gt;uint8_t ELo = 0x00;&lt;BR /&gt;&lt;BR /&gt;I2C_TRAN;&lt;BR /&gt;I2C_M_START;&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;BR /&gt;I2C1-&amp;gt;D = LCD_ADDR_W;&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C1-&amp;gt;D = ((c&amp;lt;&amp;lt;4) | ELo);&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C1-&amp;gt;D = ((c&amp;lt;&amp;lt;4) | EHi);&lt;BR /&gt;I2C_WAIT;&lt;BR /&gt;I2C_M_STOP;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define I2C_TRAN I2C1-&amp;gt;C1 |= I2C_C1_TX_MASK&lt;/P&gt;&lt;P&gt;#define I2C_M_START I2C1-&amp;gt;C1 |= I2C_C1_MST_MASK&lt;BR /&gt;#define I2C_M_STOP I2C1-&amp;gt;C1 &amp;amp;= ~I2C_C1_MST_MASK&lt;/P&gt;&lt;P&gt;#define I2C_WAIT while((I2C1-&amp;gt;S &amp;amp; I2C_S_IICIF_MASK)==0) {} \&lt;BR /&gt;I2C1-&amp;gt;S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;#define LCD_ADDR_W 0x4E&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2022 18:04:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1556743#M64327</guid>
      <dc:creator>galenmoir</dc:creator>
      <dc:date>2022-11-20T18:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z i2C LCD module configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1558724#M64344</link>
      <description>&lt;P lang="en-US"&gt;Hi, thank you for your interest in NXP products&lt;/P&gt;
&lt;P lang="en-US"&gt;In this case I would like to recommend you import an example of I2C from our SDK in MCUXpresso, this will show you how to set up your device then you will be able to modify the code in base your project needs.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ramon_delaVega_0-1669222064750.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/201508iDD643AD561BEFAFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ramon_delaVega_0-1669222064750.png" alt="Ramon_delaVega_0-1669222064750.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P lang="en-US"&gt;The steps to import a new project:&lt;/P&gt;
&lt;UL type="disc"&gt;
&lt;LI lang="en-US"&gt;Tap in the Import SDK examples&lt;/LI&gt;
&lt;LI lang="en-US"&gt;Choose your development board&lt;/LI&gt;
&lt;LI lang="en-US"&gt;Choose Driver examples and the look up for i2c and select one&lt;/LI&gt;
&lt;/UL&gt;
&lt;P lang="en-US"&gt;Also, you can consult this page for more information about i2c:&amp;nbsp;&lt;A href="https://mcuxpresso.nxp.com/api_doc/dev/116/group__i2c__slave__driver.html" target="_blank"&gt;MCUXpresso SDK API Reference Manual: I2C Slave Driver (nxp.com)&lt;/A&gt;&lt;/P&gt;
&lt;P lang="en-US"&gt;I hope this information help you, if you have any other question, please let me know.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 16:56:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1558724#M64344</guid>
      <dc:creator>Ramon_Vega</dc:creator>
      <dc:date>2022-11-23T16:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z i2C LCD module configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1608051#M64791</link>
      <description>&lt;P&gt;im using the KL26Z and ive tried for a few weeks now to get this to work with the example sdk. did you end up getting the LCD to work?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 02:27:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1608051#M64791</guid>
      <dc:creator>Nguye218</dc:creator>
      <dc:date>2023-03-02T02:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z i2C LCD module configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1609389#M64806</link>
      <description>&lt;P&gt;Its likely that the LCD has a 5V power supply. They alot of the time on teh i2c breakouts it seems, have internal pull up resistors on the SDA and SCL pins that pull it up to the power supply of the LCD which is 5V. If youre not careful and plug that into your kl25Z which is 3.3v tolerant on the pins, then you will burn out your pins. I reccomend&lt;/P&gt;&lt;P&gt;1.) powering the LCD with 5V seperated from your microcontroller&lt;/P&gt;&lt;P&gt;2.) measuring the voltages on your SCD and SCL lines&lt;/P&gt;&lt;P&gt;3.) If ~5V on SCL and SDA lines, get a soldering iron, use a continuity device on a multi meter to track down which are the pull down resistors and de solder them from the I2C break out. Also worth using your old I2C pins on your microcontroller as a GPIO and see if they can toggle high and low, if they cant then the 5V previously probably burnt out your pins. RIP.&lt;/P&gt;&lt;P&gt;4.) Use a new breakout connection on board that supports I2C. Use external pull up resistors from 3.3V to your SDA and SCL lines. try 3.6 or 4k. ohm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;See if that fixes your inital problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 18:23:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25Z-i2C-LCD-module-configuration/m-p/1609389#M64806</guid>
      <dc:creator>galenmoir</dc:creator>
      <dc:date>2023-03-03T18:23:24Z</dc:date>
    </item>
  </channel>
</rss>

