<?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: Port configuration in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393715#M21555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Eliezer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Configure a GPIO pin is very easy. You must follow the next steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. As any other peripheral, enable the clock gating for the LED's PORT. This can be seen in the &lt;STRONG&gt;Chapter 12 - System Integration Module (SIM)&lt;/STRONG&gt; in the &lt;A href="http://cache.freescale.com/files/32bit/doc/ref_manual/KL05P48M48SF1RM.pdf" rel="nofollow noopener noreferrer" title="http://cache.freescale.com/files/32bit/doc/ref_manual/KL05P48M48SF1RM.pdf" target="_blank"&gt;Reference Manual&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607091734709 jive_text_macro" data-renderedposition="134_0_1215_16" jivemacro_uid="_14340607091734709"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Select the pin function in the Signal Multiplexing module. This can be seen in the &lt;STRONG&gt;Chapter 10 - Signal Multiplexing and Signal Descriptions&lt;/STRONG&gt; (Pinout table) in the Reference manual. In this case, for the GPIO function the alternative 1 has to be chosen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607318377487 jive_text_macro" data-renderedposition="234_0_1215_32" jivemacro_uid="_14340607318377487" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR10 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //Blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR11 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //PORTB11 as input pin.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the configured pin is needed as input you must configure the pull up or pull down resistor in this register (PE and PS bits) as well as the interrupts (IRQC bits). This can be seen in the &lt;STRONG&gt;Chapter 11 - Port control and interrupts (PORT)&lt;/STRONG&gt; in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Select the pin direction (input or output). There is a 32-bit register for each port. If the n bit is set then the n pin for that port will be configured as output but if it is cleared it will be configured as input. This can be seen in the &lt;STRONG&gt;Chapter 38 - General-Purpose Input/Output (GPIO)&lt;/STRONG&gt; in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607579061778 jive_text_macro" data-renderedposition="413_0_1215_32" jivemacro_uid="_14340607579061778" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR |= (1 &amp;lt;&amp;lt; 10);&amp;nbsp;&amp;nbsp;&amp;nbsp; //Output pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR &amp;amp;= ~(1 &amp;lt;&amp;lt; 11);&amp;nbsp;&amp;nbsp; //Input pin.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. If you want to change the state of the output pin you need to set some of the next registers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PSOR - Set the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PCOR - Clear the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PTOR - Toggle the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example to set the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607773305547 jive_text_macro" data-renderedposition="613_0_1215_16" jivemacro_uid="_14340607773305547"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PSOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To clear the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607856472293 jive_text_macro" data-renderedposition="692_0_1215_16" jivemacro_uid="_14340607856472293"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PCOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To toggle the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607917892211 jive_text_macro" data-renderedposition="771_0_1215_16" jivemacro_uid="_14340607917892211" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PTOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to read the state of the input pin you need to read the value of the next register. &lt;STRONG&gt;If the next expression is true, the input pin is in high state, otherwise it is in low state&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14370638266568745" data-renderedposition="850_0_1215_16" jivemacro_uid="_14370638266568745" modifiedtitle="true"&gt;&lt;P&gt;(GPIOB_PDIR &amp;amp; (1 &amp;lt;&amp;lt; 11))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Full code:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_1434060994060120 jive_macro_code jive_text_macro" data-renderedposition="929_0_1215_624" jivemacro_uid="_1434060994060120" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. As any other peripheral, enable the clock gating for the LED's PORT. This can be seen in the Chapter 12 - System Integration Module (SIM) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Select the pin function in the Signal Multiplexing module. This can be seen in the Chapter 10 - Signal Multiplexing and Signal Descriptions (Pinout table) in the Reference manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // In this case, for the GPIO function the alternative 1 has to be chosen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR10 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //Blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR11 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //PORTB11 as input pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If the configured pin is needed as input you must configure the pull up or pull down resistor in this register (PE and PS bits) as well as the interrupts (IRQC bits). This can be seen in the Chapter 11 - Port control and interrupts (PORT) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 3. Select the pin direction (input or output). There is a 32-bit register for each port. If the n bit is set then the n pin for that port will be configured as output but if it is cleared it will be configured as input. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //This can be seen in the Chapter 38 - General-Purpose Input/Output (GPIO) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR |= (1 &amp;lt;&amp;lt; 10);&amp;nbsp;&amp;nbsp;&amp;nbsp; //Output pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR &amp;amp;= ~(1 &amp;lt;&amp;lt; 11);&amp;nbsp;&amp;nbsp; //Input pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //4. If you want to change the state of the output pin you need to set some of the next registers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PSOR - Set the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PCOR - Clear the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PTOR - Toggle the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //For example to set the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PSOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // To clear the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PCOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // To toggle the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PTOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If you want to read the state of the input pin you need to read the value of the next register.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If the next expression is true, the input pin is in high state, otherwise it is in low state&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(GPIOB_PDIR &amp;amp; (1 &amp;lt;&amp;lt; 11))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Input pin is in high state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Input pin is in low state. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Earl Orlando.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #eb7a3d;"&gt;&lt;STRONG&gt;/* If this post answers your question please click the &lt;EM&gt;Correct Answer &lt;/EM&gt;button. */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jun 2015 22:17:04 GMT</pubDate>
    <dc:creator>EarlOrlando</dc:creator>
    <dc:date>2015-06-11T22:17:04Z</dc:date>
    <item>
      <title>Port configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393714#M21554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello friends. I'm programming my first kinets a MKL05, and I am unable to configure the ports to work as input or output.&lt;/P&gt;&lt;P&gt;I've read and re-read the datasheet but could not understand this very confusing.&lt;/P&gt;&lt;P&gt;Example of what I want to do is set the PTB8 pin as output to light an LED. I will be very grateful for the help.&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 19:02:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393714#M21554</guid>
      <dc:creator>eliezeroc</dc:creator>
      <dc:date>2015-06-11T19:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Port configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393715#M21555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Eliezer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Configure a GPIO pin is very easy. You must follow the next steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. As any other peripheral, enable the clock gating for the LED's PORT. This can be seen in the &lt;STRONG&gt;Chapter 12 - System Integration Module (SIM)&lt;/STRONG&gt; in the &lt;A href="http://cache.freescale.com/files/32bit/doc/ref_manual/KL05P48M48SF1RM.pdf" rel="nofollow noopener noreferrer" title="http://cache.freescale.com/files/32bit/doc/ref_manual/KL05P48M48SF1RM.pdf" target="_blank"&gt;Reference Manual&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607091734709 jive_text_macro" data-renderedposition="134_0_1215_16" jivemacro_uid="_14340607091734709"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Select the pin function in the Signal Multiplexing module. This can be seen in the &lt;STRONG&gt;Chapter 10 - Signal Multiplexing and Signal Descriptions&lt;/STRONG&gt; (Pinout table) in the Reference manual. In this case, for the GPIO function the alternative 1 has to be chosen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607318377487 jive_text_macro" data-renderedposition="234_0_1215_32" jivemacro_uid="_14340607318377487" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR10 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //Blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR11 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //PORTB11 as input pin.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the configured pin is needed as input you must configure the pull up or pull down resistor in this register (PE and PS bits) as well as the interrupts (IRQC bits). This can be seen in the &lt;STRONG&gt;Chapter 11 - Port control and interrupts (PORT)&lt;/STRONG&gt; in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Select the pin direction (input or output). There is a 32-bit register for each port. If the n bit is set then the n pin for that port will be configured as output but if it is cleared it will be configured as input. This can be seen in the &lt;STRONG&gt;Chapter 38 - General-Purpose Input/Output (GPIO)&lt;/STRONG&gt; in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607579061778 jive_text_macro" data-renderedposition="413_0_1215_32" jivemacro_uid="_14340607579061778" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR |= (1 &amp;lt;&amp;lt; 10);&amp;nbsp;&amp;nbsp;&amp;nbsp; //Output pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR &amp;amp;= ~(1 &amp;lt;&amp;lt; 11);&amp;nbsp;&amp;nbsp; //Input pin.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. If you want to change the state of the output pin you need to set some of the next registers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PSOR - Set the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PCOR - Clear the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PTOR - Toggle the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example to set the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607773305547 jive_text_macro" data-renderedposition="613_0_1215_16" jivemacro_uid="_14340607773305547"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PSOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To clear the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607856472293 jive_text_macro" data-renderedposition="692_0_1215_16" jivemacro_uid="_14340607856472293"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PCOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To toggle the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14340607917892211 jive_text_macro" data-renderedposition="771_0_1215_16" jivemacro_uid="_14340607917892211" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PTOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to read the state of the input pin you need to read the value of the next register. &lt;STRONG&gt;If the next expression is true, the input pin is in high state, otherwise it is in low state&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14370638266568745" data-renderedposition="850_0_1215_16" jivemacro_uid="_14370638266568745" modifiedtitle="true"&gt;&lt;P&gt;(GPIOB_PDIR &amp;amp; (1 &amp;lt;&amp;lt; 11))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Full code:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_1434060994060120 jive_macro_code jive_text_macro" data-renderedposition="929_0_1215_624" jivemacro_uid="_1434060994060120" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. As any other peripheral, enable the clock gating for the LED's PORT. This can be seen in the Chapter 12 - System Integration Module (SIM) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Select the pin function in the Signal Multiplexing module. This can be seen in the Chapter 10 - Signal Multiplexing and Signal Descriptions (Pinout table) in the Reference manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // In this case, for the GPIO function the alternative 1 has to be chosen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR10 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //Blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB_PCR11 |= (PORT_PCR_MUX(1));&amp;nbsp;&amp;nbsp;&amp;nbsp; //PORTB11 as input pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If the configured pin is needed as input you must configure the pull up or pull down resistor in this register (PE and PS bits) as well as the interrupts (IRQC bits). This can be seen in the Chapter 11 - Port control and interrupts (PORT) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 3. Select the pin direction (input or output). There is a 32-bit register for each port. If the n bit is set then the n pin for that port will be configured as output but if it is cleared it will be configured as input. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //This can be seen in the Chapter 38 - General-Purpose Input/Output (GPIO) in the Reference Manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR |= (1 &amp;lt;&amp;lt; 10);&amp;nbsp;&amp;nbsp;&amp;nbsp; //Output pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PDDR &amp;amp;= ~(1 &amp;lt;&amp;lt; 11);&amp;nbsp;&amp;nbsp; //Input pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //4. If you want to change the state of the output pin you need to set some of the next registers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PSOR - Set the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PCOR - Clear the pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; * GPIOx_PTOR - Toggle the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //For example to set the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PSOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // To clear the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PCOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // To toggle the blue LED in the FRDM-KL05Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOB_PTOR |= (1 &amp;lt;&amp;lt; 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If you want to read the state of the input pin you need to read the value of the next register.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If the next expression is true, the input pin is in high state, otherwise it is in low state&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(GPIOB_PDIR &amp;amp; (1 &amp;lt;&amp;lt; 11))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Input pin is in high state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Input pin is in low state. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Earl Orlando.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #eb7a3d;"&gt;&lt;STRONG&gt;/* If this post answers your question please click the &lt;EM&gt;Correct Answer &lt;/EM&gt;button. */&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 22:17:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393715#M21555</guid>
      <dc:creator>EarlOrlando</dc:creator>
      <dc:date>2015-06-11T22:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Port configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393716#M21556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to configure GPIO ports to read the data from a rain drop sensor, using FRDMKEAZ128. Will the process be similar as mentioned above for KLZ05?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Apr 2017 18:47:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Port-configuration/m-p/393716#M21556</guid>
      <dc:creator>sruthikilari</dc:creator>
      <dc:date>2017-04-19T18:47:21Z</dc:date>
    </item>
  </channel>
</rss>

