<?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 K20 I2C_PDD.h Example in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853902#M51263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a simple example of using the I2C_PDD.h functions?&amp;nbsp; Something that will initialize the i2c interface, set a slave address, and send some bytes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Apr 2019 16:45:25 GMT</pubDate>
    <dc:creator>ryan_pearson</dc:creator>
    <dc:date>2019-04-09T16:45:25Z</dc:date>
    <item>
      <title>K20 I2C_PDD.h Example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853902#M51263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a simple example of using the I2C_PDD.h functions?&amp;nbsp; Something that will initialize the i2c interface, set a slave address, and send some bytes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Apr 2019 16:45:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853902#M51263</guid>
      <dc:creator>ryan_pearson</dc:creator>
      <dc:date>2019-04-09T16:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: K20 I2C_PDD.h Example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853903#M51264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan,&lt;/P&gt;&lt;P&gt;Please refer the Typical Usages of Component I2C_LDD, they use I2C_PDD.h functions.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="I2C_LDD I2C_PDD.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/79438i83B1FCFE9DC8F7EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="I2C_LDD I2C_PDD.png" alt="I2C_LDD I2C_PDD.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="I2C1_Init.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/79465i24FFC48D4451F5FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="I2C1_Init.png" alt="I2C1_Init.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 06:47:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853903#M51264</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2019-04-11T06:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: K20 I2C_PDD.h Example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853904#M51265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robin!&amp;nbsp; I added the I2C LDD to my project, but I still don't see any activity on the I2C lines.&amp;nbsp; Do you see anything missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;MyI2CPtr = CI2C1_Init(NULL);&lt;/P&gt;&lt;P&gt;dat[0] = 0x8C;&lt;BR /&gt; dat[1] = 0xFD;&lt;BR /&gt; dat[2] = 0xC3;&lt;BR /&gt; dat[3] = 0x19;&lt;BR /&gt; CI2C1_MasterSendBlock(MyI2CPtr, (void *)dat, 4, LDD_I2C_SEND_STOP);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Generated Init function:&lt;/P&gt;&lt;P&gt;LDD_TDeviceData* CI2C1_Init(LDD_TUserData *UserDataPtr)&lt;BR /&gt;{&lt;BR /&gt; /* Allocate HAL device structure */&lt;BR /&gt; CI2C1_TDeviceData *DeviceDataPrv;&lt;BR /&gt; /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */&lt;BR /&gt; DeviceDataPrv = &amp;amp;DeviceDataPrv__DEFAULT_RTOS_ALLOC;&lt;/P&gt;&lt;P&gt;DeviceDataPrv-&amp;gt;UserData = UserDataPtr; /* Store the RTOS device structure */&lt;/P&gt;&lt;P&gt;/* Allocate interrupt vector */&lt;BR /&gt; /* {Default RTOS Adapter} Set interrupt vector: IVT is static, ISR parameter is passed by the global variable */&lt;BR /&gt; INT_I2C0__DEFAULT_RTOS_ISRPARAM = DeviceDataPrv;&lt;BR /&gt; DeviceDataPrv-&amp;gt;SerFlag = 0x00U; /* Reset all flags */&lt;BR /&gt; DeviceDataPrv-&amp;gt;SendStop = LDD_I2C_SEND_STOP; /* Set variable for sending stop condition (for master mode) */&lt;BR /&gt; DeviceDataPrv-&amp;gt;InpLenM = 0x00U; /* Set zero counter of data of reception */&lt;BR /&gt; DeviceDataPrv-&amp;gt;OutLenM = 0x00U; /* Set zero counter of data of transmission */&lt;BR /&gt; /* SIM_SCGC4: I2C0=1 */&lt;BR /&gt; SIM_SCGC4 |= SIM_SCGC4_I2C0_MASK;&lt;BR /&gt; /* I2C0_C1: IICEN=0,IICIE=0,MST=0,TX=0,TXAK=0,RSTA=0,WUEN=0,DMAEN=0 */&lt;BR /&gt; I2C0_C1 = 0x00U; /* Clear control register */&lt;BR /&gt; /* I2C0_S: TCF=0,IAAS=0,BUSY=0,ARBL=0,RAM=0,SRW=0,IICIF=1,RXAK=0 */&lt;BR /&gt; I2C0_S = I2C_S_IICIF_MASK; /* Clear interrupt flag */&lt;BR /&gt; /* PORTB_PCR1: ISF=0,MUX=2 */&lt;BR /&gt; PORTB_PCR1 = (uint32_t)((PORTB_PCR1 &amp;amp; (uint32_t)~(uint32_t)(&lt;BR /&gt; PORT_PCR_ISF_MASK |&lt;BR /&gt; PORT_PCR_MUX(0x05)&lt;BR /&gt; )) | (uint32_t)(&lt;BR /&gt; PORT_PCR_MUX(0x02)&lt;BR /&gt; ));&lt;BR /&gt; PORT_PDD_SetPinOpenDrain(PORTB_BASE_PTR, 0x01u, PORT_PDD_OPEN_DRAIN_ENABLE); /* Set SDA pin as open drain */&lt;BR /&gt; /* PORTB_PCR0: ISF=0,MUX=2 */&lt;BR /&gt; PORTB_PCR0 = (uint32_t)((PORTB_PCR0 &amp;amp; (uint32_t)~(uint32_t)(&lt;BR /&gt; PORT_PCR_ISF_MASK |&lt;BR /&gt; PORT_PCR_MUX(0x05)&lt;BR /&gt; )) | (uint32_t)(&lt;BR /&gt; PORT_PCR_MUX(0x02)&lt;BR /&gt; ));&lt;BR /&gt; PORT_PDD_SetPinOpenDrain(PORTB_BASE_PTR, 0x00u, PORT_PDD_OPEN_DRAIN_ENABLE); /* Set SCL pin as open drain */&lt;BR /&gt; /* NVICIP11: PRI11=0x80 */&lt;BR /&gt; NVICIP11 = NVIC_IP_PRI11(0x80);&lt;BR /&gt; /* NVICISER0: SETENA|=0x0800 */&lt;BR /&gt; NVICISER0 |= NVIC_ISER_SETENA(0x0800);&lt;BR /&gt; /* I2C0_C2: GCAEN=0,ADEXT=0,HDRS=0,SBRC=0,RMEN=0,AD=0 */&lt;BR /&gt; I2C0_C2 = I2C_C2_AD(0x00);&lt;BR /&gt; /* I2C0_FLT: ??=0,??=0,??=0,FLT=0 */&lt;BR /&gt; I2C0_FLT = I2C_FLT_FLT(0x00); /* Set glitch filter register */&lt;BR /&gt; /* I2C0_SMB: FACK=0,ALERTEN=0,SIICAEN=0,TCKSEL=0,SLTF=1,SHTF1=0,SHTF2=0,SHTF2IE=0 */&lt;BR /&gt; I2C0_SMB = I2C_SMB_SLTF_MASK;&lt;BR /&gt; /* I2C0_F: MULT=2,ICR=0x1E */&lt;BR /&gt; I2C0_F = (I2C_F_MULT(0x02) | I2C_F_ICR(0x1E)); /* Set prescaler bits */&lt;BR /&gt; I2C_PDD_EnableDevice(I2C0_BASE_PTR, PDD_ENABLE); /* Enable device */&lt;BR /&gt; I2C_PDD_EnableInterrupt(I2C0_BASE_PTR); /* Enable interrupt */&lt;BR /&gt; /* Registration of the device structure */&lt;BR /&gt; PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_CI2C1_ID,DeviceDataPrv);&lt;BR /&gt; return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the data data structure */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The generated MasterSendBlock function:&lt;/P&gt;&lt;P&gt;LDD_TError CI2C1_MasterSendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, LDD_I2C_TSize Size, LDD_I2C_TSendStop SendStop)&lt;BR /&gt;{&lt;BR /&gt; CI2C1_TDeviceData *DeviceDataPrv = (CI2C1_TDeviceData *)DeviceDataPtr;&lt;/P&gt;&lt;P&gt;if (Size == 0x00U) { /* Test variable Size on zero */&lt;BR /&gt; return ERR_OK; /* If zero then OK */&lt;BR /&gt; }&lt;BR /&gt; if (DeviceDataPrv-&amp;gt;SendStop == LDD_I2C_SEND_STOP) {&lt;BR /&gt; if ((I2C_PDD_GetBusStatus(I2C0_BASE_PTR) == I2C_PDD_BUS_BUSY) || /* Is the bus busy? */ \&lt;BR /&gt; ((DeviceDataPrv-&amp;gt;SerFlag &amp;amp; MASTER_IN_PROGRES) != 0x00U) || \&lt;BR /&gt; (DeviceDataPrv-&amp;gt;OutLenM != 0x00U)) {&lt;BR /&gt; return ERR_BUSY; /* If yes then error */&lt;BR /&gt; }&lt;BR /&gt; } else {&lt;BR /&gt; if (((DeviceDataPrv-&amp;gt;SerFlag &amp;amp; MASTER_IN_PROGRES) != 0x00U) || /* Is the bus busy? */ \&lt;BR /&gt; (DeviceDataPrv-&amp;gt;OutLenM != 0x00U)) {&lt;BR /&gt; return ERR_BUSY; /* If yes then error */&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; /* {Default RTOS Adapter} Critical section begin, general PE function is used */&lt;BR /&gt; EnterCritical();&lt;BR /&gt; DeviceDataPrv-&amp;gt;SerFlag |= MASTER_IN_PROGRES; /* Set flag "busy" */&lt;BR /&gt; DeviceDataPrv-&amp;gt;OutPtrM = (uint8_t *)BufferPtr; /* Save pointer to data for transmitting */&lt;BR /&gt; DeviceDataPrv-&amp;gt;OutLenM = Size; /* Set the counter of output bufer's content */&lt;BR /&gt; DeviceDataPrv-&amp;gt;SendStop = SendStop; /* Set generating stop condition */&lt;BR /&gt; I2C_PDD_SetTransmitMode(I2C0_BASE_PTR, I2C_PDD_TX_DIRECTION); /* Set TX mode */&lt;BR /&gt; if (I2C_PDD_GetMasterMode(I2C0_BASE_PTR) == I2C_PDD_MASTER_MODE) { /* Is device in master mode? */&lt;BR /&gt; I2C_PDD_RepeatStart(I2C0_BASE_PTR); /* If yes then repeat start cycle generated */&lt;BR /&gt; } else {&lt;BR /&gt; I2C_PDD_SetMasterMode(I2C0_BASE_PTR, I2C_PDD_MASTER_MODE); /* If no then start signal generated */&lt;BR /&gt; }&lt;BR /&gt; I2C_PDD_WriteDataReg(I2C0_BASE_PTR, 0x46U); /* Send slave address */&lt;BR /&gt; /* {Default RTOS Adapter} Critical section end, general PE function is used */&lt;BR /&gt; ExitCritical();&lt;BR /&gt; return ERR_OK; /* OK */&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2019 21:01:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853904#M51265</guid>
      <dc:creator>ryan_pearson</dc:creator>
      <dc:date>2019-04-16T21:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: K20 I2C_PDD.h Example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853905#M51266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you forgot to add external pull-up resistors.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="external pull-up resistors.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/61934i5BC581D14BDE8CF9/image-size/large?v=v2&amp;amp;px=999" role="button" title="external pull-up resistors.png" alt="external pull-up resistors.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2019 07:14:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853905#M51266</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2019-04-17T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: K20 I2C_PDD.h Example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853906#M51267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Robin, we did discover a problem with a pull-up resistor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2019 18:47:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-I2C-PDD-h-Example/m-p/853906#M51267</guid>
      <dc:creator>ryan_pearson</dc:creator>
      <dc:date>2019-04-17T18:47:48Z</dc:date>
    </item>
  </channel>
</rss>

