<?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: Reading Input using PDIR(Port Data Input Register) in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415930#M23670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can select a pull-up or pull-down internal resistor for the pins. There are some pins, like the SDA and SCL for I2C functionality, that are configured as true open drain when selected; in this case the pull up or down internal resistor has no effect on them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to consider also that according to the Datasheet the internal pull-up resistor has a value of 20 to 50 kOhms, it will probably will not be enough for some applications but, like in this case, will help you to ensure a constant value in the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can pull-down the PTC3 by selecting in the PORTx_PCRn register PE= 1 and PS= 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this information can help you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Adrian Sanchez Cano&lt;BR /&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, 24 Jun 2015 14:48:43 GMT</pubDate>
    <dc:creator>adriancano</dc:creator>
    <dc:date>2015-06-24T14:48:43Z</dc:date>
    <item>
      <title>Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415927#M23667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a FRDM-KL46Z Board.I am using Keil uvision.I am trying to read from a switch and turn on a led.When the switch is pressed,the LED should turn on.The code is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "MKL46Z4.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Device header&lt;/P&gt;&lt;P&gt;void InitLED(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SCGC5=SIM_SCGC5_PORTD_MASK;//Clock to PortD&lt;/P&gt;&lt;P&gt;&amp;nbsp; PORTD-&amp;gt;PCR[5]=256;//PIN 5 of portd as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PDDR=(1u&amp;lt;&amp;lt;5);//PIN 5 of portd as OUTPUT&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void InitSW1(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SCGC5=SIM_SCGC5_PORTC_MASK;//Clock to PortC&lt;/P&gt;&lt;P&gt;&amp;nbsp; PORTC-&amp;gt;PCR[3]=256;//PIN 5 of portd as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTC-&amp;gt;PDDR=(0u&amp;lt;&amp;lt;3);//PIN 5 of portd as INPUT&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitLED();&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitSW1();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(PTC-&amp;gt;PDIR==(0u&amp;lt;&amp;lt;3))//Read 0 switch pressed&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PCOR=(1u&amp;lt;&amp;lt;5);//LED turns on&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if(PTC-&amp;gt;PDIR==(1u&amp;lt;&amp;lt;3))//Read 1 switch not pressed&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PSOR=(1u&amp;lt;&amp;lt;5);//Led turns off&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;when i download the code on the board,the led turns on without even pressing the onboard button and i dont know what is the problem with the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Jun 2015 15:54:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415927#M23667</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-06-20T15:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415928#M23668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to enable the internal Pull-up for the pin since in the Board are not externally pulled-up. To enable the pull-up you need to write 1 to the PS and PE fields in the PCR register.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pcr.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/45469i6BC0BB00AB834648/image-size/large?v=v2&amp;amp;px=999" role="button" title="pcr.jpg" alt="pcr.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope this information can help you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Adrian Sanchez Cano&lt;BR /&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>Sat, 20 Jun 2015 21:12:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415928#M23668</guid>
      <dc:creator>adriancano</dc:creator>
      <dc:date>2015-06-20T21:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415929#M23669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,This worked.&lt;/P&gt;&lt;P&gt;Can I make any pin as a pullup / pulldown?&lt;/P&gt;&lt;P&gt;Can this switch pin PTC3 become pulldown? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 16:31:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415929#M23669</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-06-23T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415930#M23670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can select a pull-up or pull-down internal resistor for the pins. There are some pins, like the SDA and SCL for I2C functionality, that are configured as true open drain when selected; in this case the pull up or down internal resistor has no effect on them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to consider also that according to the Datasheet the internal pull-up resistor has a value of 20 to 50 kOhms, it will probably will not be enough for some applications but, like in this case, will help you to ensure a constant value in the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can pull-down the PTC3 by selecting in the PORTx_PCRn register PE= 1 and PS= 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this information can help you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Adrian Sanchez Cano&lt;BR /&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, 24 Jun 2015 14:48:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415930#M23670</guid>
      <dc:creator>adriancano</dc:creator>
      <dc:date>2015-06-24T14:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415931#M23671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to make the PTC3(Switch1)pin as pull-down but it is not working.The code is as follows:&lt;/P&gt;&lt;P&gt;#include "MKL46Z4.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Device header&lt;/P&gt;&lt;P&gt;void InitLED(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SCGC5=SIM_SCGC5_PORTD_MASK;//Clock to PortD&lt;/P&gt;&lt;P&gt;&amp;nbsp; PORTD-&amp;gt;PCR[5]=256;//PIN 5 of portd as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PDDR=(1u&amp;lt;&amp;lt;5);//PIN 5 of portd as OUTPUT&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void InitSW1(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SCGC5=SIM_SCGC5_PORTC_MASK;//Clock to PortC&lt;/P&gt;&lt;P&gt;&amp;nbsp; PORTC-&amp;gt;PCR[3]=256|2;//PIN 3 of portc as GPIO and pullup/pulldown+pulldown&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTC-&amp;gt;PDDR=(0u&amp;lt;&amp;lt;3);//PIN 5 of portd as INPUT&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitLED();&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitSW1();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(PTC-&amp;gt;PDIR==(0u&amp;lt;&amp;lt;3))//Read 0 switch pressed&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PCOR=(1u&amp;lt;&amp;lt;5);//LED turns on&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if(PTC-&amp;gt;PDIR==(1u&amp;lt;&amp;lt;3))//Read 1 switch not pressed&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PSOR=(1u&amp;lt;&amp;lt;5);//Led turns off&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;When I download the above code to the board the led switches on but when i press the switch it does not switch off.The schematic says that the switch is of pull-up type ,can i really use it as a pull-down?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2015 16:01:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415931#M23671</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-06-24T16:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Input using PDIR(Port Data Input Register)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415932#M23672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the schematic the Button is connected to GND, this means that any time you pressed the value it will drive is 0 (zero). The same way with the internal pull-down the value of the pin is 0 and when you press the button the value will not change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the pull-up the value of the pin is 1 and when you press the button the value will be 0 because the button will short to GND. This means you cannot use pull-down for the button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this information can help you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Adrian Sanchez Cano&lt;BR /&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, 25 Jun 2015 18:44:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-Input-using-PDIR-Port-Data-Input-Register/m-p/415932#M23672</guid>
      <dc:creator>adriancano</dc:creator>
      <dc:date>2015-06-25T18:44:04Z</dc:date>
    </item>
  </channel>
</rss>

