<?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: MKL02Z PTA2(SWD_DIO) GPIO setup in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502782#M31522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just searched an SDK project and found this function in &lt;SPAN style="text-decoration: underline;"&gt;fsl_port.h&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;* @param base&amp;nbsp;&amp;nbsp; PORT peripheral base pointer.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;* @param pin&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT pin number.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;* @param config PORT PCR register configuration structure.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;static inline void PORT_SetPinConfig(PORT_Type *base, uint32_t pin, const port_pin_config_t *config)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert(config);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t addr = (uint32_t)&amp;amp;base-&amp;gt;PCR[pin];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(volatile uint16_t *)(addr) = *((const uint16_t *)config);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each pin has a pin mux and some default to GPIO but others to peripheral functions (or disabled). PTA2 on the KL02 defaults to SWD_DIO and so GPIO operatiosn will have no effect until its MUX setting is configured to a port.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The actual command is to write &lt;BR /&gt;&lt;STRONG&gt;PORTA_PCR2 = 0x00000100; // set GPIO on PTA2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beware that programming this pin to output will stop the debugger working....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;EM&gt;&lt;SPAN&gt;For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fsupport.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/support.html&lt;/A&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Sep 2018 13:45:05 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2018-09-13T13:45:05Z</dc:date>
    <item>
      <title>MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502775#M31515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi i have question about MKL02Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i try PTA2 is gpio output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but output is not change&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there anythig i miss?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz, thx for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;have a nice day.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2016 06:09:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502775#M31515</guid>
      <dc:creator>OilCastle</dc:creator>
      <dc:date>2016-05-26T06:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502776#M31516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You can find different examples of configuration like GPIO, in the next link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.nxp.com/webapp/sps/download/license.jsp?colCode=KL02-SC&amp;amp;location=null&amp;amp;Parent_nodeId=1369087750761754789513&amp;amp;Parent_pageType=product&amp;amp;Parent_nodeId=1369087750761754789513&amp;amp;Parent_pageType=product" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.nxp.com/webapp/sps/download/license.jsp?colCode=KL02-SC&amp;amp;location=null&amp;amp;Parent_nodeId=1369087750761754789513&amp;amp;Parent_pageType=product&amp;amp;Parent_nodeId=1369087750761754789513&amp;amp;Parent_pageType=product&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using KSDK, the next example could help you with the configuration&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14646476738993381" data-renderedposition="216_8_1155_240" jivemacro_uid="_14646476738993381" modifiedtitle="true"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: #3f7f5f;"&gt;/* enable clock for PORTs */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLOCK_SYS_EnablePortClock(PORTA_IDX);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLOCK_SYS_EnablePortClock(PORTB_IDX);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="ES-MX" style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;configure_gpio_pins( PORTA_IDX );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;configure_gpio_pins( PORTB_IDX );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIO_DRV_OutputPinInit(&amp;amp;&lt;SPAN style="background: silver;"&gt;gpioPins&lt;/SPAN&gt;[0]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIO_DRV_OutputPinInit(&amp;amp;ledPins[1]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: #3f7f5f;"&gt;/* This for loop should be replaced. By default this loop allows a single stepping. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;STRONG style="color: #7f0055; font-size: 10.0pt; font-family: Consolas;"&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt; (;;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIO_DRV_TogglePinOutput( &lt;/SPAN&gt;&lt;EM style="color: #0000c0; font-size: 10.0pt; font-family: Consolas;"&gt;kGpioLED1&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIO_DRV_TogglePinOutput( GPIO_MAKE_PIN(GPIOA_IDX,&amp;nbsp; 2));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Mario&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 22:35:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502776#M31516</guid>
      <dc:creator>mario_castaneda</dc:creator>
      <dc:date>2016-05-30T22:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502777#M31517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks very much for your reply, but...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think it is not helpful for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cause, i don`t use KSDK,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i did setup gpio output on PTA2 so sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i`m still working on it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;PTA2 is only gpio output cannot change output in my case.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;any other output works so fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;PTA2 input works fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;only output is problem&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;anyway, thanks for your kindness&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;have a nice day&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 07:50:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502777#M31517</guid>
      <dc:creator>OilCastle</dc:creator>
      <dc:date>2016-06-03T07:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502778#M31518</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 show your code so that it is possible to see what is missing in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However this is how to configure the PTA2 output - maybe you see what is missing in your code from it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SIM_SCGC5 |= SIM_SCGC5_PORTA; // apply clock to port&lt;/P&gt;&lt;P&gt;PORTA_GPCLR = (((0x04) &amp;lt;&amp;lt; 16) | (PORT_MUX_GPIO)); // configure as GPIO&lt;/P&gt;&lt;P&gt;GPIOA_PDDR |= 0x04; // set to output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 09:47:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502778#M31518</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-06-03T09:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502779#M31519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jun-Young Lee,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how are you?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you solved this problem?? I've just got stuck on this same issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try to configure PTA2 as a simple output but nothig occurs, when I try to set it to "1" there's no change on the pin voltage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* pinout configuration variables */&lt;BR /&gt;gpio_pin_config_t dc_rseg_config = {kGPIO_DigitalOutput, true};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GPIO_PinInit(kGPIO_PORTA, 2, &amp;amp;dc_rseg_config);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 18:09:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502779#M31519</guid>
      <dc:creator>btruden</dc:creator>
      <dc:date>2018-09-12T18:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502780#M31520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't use the environment that you are working with but taking a quick look I have the feeling that you need to call two different routines to configure it (unless the pin defaults to its GPIO mode).&lt;/P&gt;&lt;P&gt;Try also using &lt;STRONG&gt;PORT_SetPinConfig()&lt;/STRONG&gt; &lt;EM&gt;before&lt;/EM&gt; to ensure the MUX is GPIO before configuring it as an output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. In case of continued problems try the uTasker projet (free open source on GitHub with Kinetis simulator to remove guess work) which just needs the following:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, (PORTA_BIT2 | PORTA_BIT5), (PORTA_BIT29), (PORT_SRE_SLOW | PORT_DSE_HIGH));&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;which would completely configure everything needed to set PTA2 and PTA5 to outputs (with certain drive characteristics) and set PTA2 to '1' and PTA5 to '0'.&lt;BR /&gt;&lt;SPAN&gt;Reference: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fforum%2Findex.php%3Ftopic%3D1875.0" rel="nofollow" target="_blank"&gt;http://www.utasker.com/forum/index.php?topic=1875.0&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 20:29:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502780#M31520</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2018-09-12T20:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502781#M31521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your prompt reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the MCU Xpresso IDE&amp;nbsp;which is the current option offered by NXP. So I use the driver libraries that comes with that IDE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tryed this, but same results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; GPIOA-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; GPIOA-&amp;gt;PSOR |= 1&amp;lt;&amp;lt;2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What exactly "&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt;PORT_SetPinConfig()"&lt;/STRONG&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;function does? I&amp;nbsp;can't&amp;nbsp;find it in the driver library that I'm using.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;How can I configure the MUX to GPIO in PTA2 at register level? which specific register must I configure?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;Below an extract of the "&lt;SPAN style="background-color: #ffffff;"&gt;GPIO_PinInit"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; : ; color: #51626f;"&gt;typedef enum _gpio_port_num&lt;BR /&gt;{&lt;BR /&gt; kGPIO_PORTA = 0U,&lt;BR /&gt; kGPIO_PORTB,&lt;BR /&gt; kGPIO_PORTC, &lt;BR /&gt; kGPIO_PORTD,&lt;BR /&gt; kGPIO_PORTE, &lt;BR /&gt; kGPIO_PORTF, &lt;BR /&gt; kGPIO_PORTG, &lt;BR /&gt; kGPIO_PORTH, &lt;BR /&gt;} gpio_port_num_t;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; : ; color: #51626f;"&gt;typedef struct _gpio_pin_config&lt;BR /&gt;{&lt;BR /&gt; gpio_pin_direction_t pinDirection; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/*!&amp;lt; GPIO direction, input or output */&lt;/STRONG&gt;&lt;STRONG style="background-color: #ffffff; : ; color: #51626f;"&gt;&lt;BR /&gt; uint8_t outputLogic; &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;&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;lt; Set a default output logic, which has no use in input */&lt;BR /&gt;} gpio_pin_config_t;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void GPIO_PinInit(gpio_port_num_t port, uint8_t pin, const gpio_pin_config_t *config)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; assert(config);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;uint8_t instance = (uint8_t)port / PORT_NUMBERS_EACH_GPIO;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; uint8_t shift = (uint8_t)port % PORT_NUMBERS_EACH_GPIO;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; GPIO_Type *base = s_gpioBases[instance];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (config-&amp;gt;pinDirection == kGPIO_DigitalInput)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PDDR &amp;amp;= ~(1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PIDR &amp;amp;= ~(1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; else&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; GPIO_PinWrite(port, pin, config-&amp;gt;outputLogic);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PDDR |= (1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PIDR |= (1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void GPIO_PinWrite(gpio_port_num_t port, uint8_t pin, uint8_t output)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; uint8_t instance = (uint8_t)port / PORT_NUMBERS_EACH_GPIO;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; uint8_t shift = (uint8_t)port % PORT_NUMBERS_EACH_GPIO;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; GPIO_Type *base = s_gpioBases[instance];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (output == 0U)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PCOR = 1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; else&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; base-&amp;gt;PSOR = 1U &amp;lt;&amp;lt; ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 12:37:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502781#M31521</guid>
      <dc:creator>btruden</dc:creator>
      <dc:date>2018-09-13T12:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502782#M31522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just searched an SDK project and found this function in &lt;SPAN style="text-decoration: underline;"&gt;fsl_port.h&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;* @param base&amp;nbsp;&amp;nbsp; PORT peripheral base pointer.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;* @param pin&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT pin number.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;* @param config PORT PCR register configuration structure.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;static inline void PORT_SetPinConfig(PORT_Type *base, uint32_t pin, const port_pin_config_t *config)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert(config);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t addr = (uint32_t)&amp;amp;base-&amp;gt;PCR[pin];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(volatile uint16_t *)(addr) = *((const uint16_t *)config);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each pin has a pin mux and some default to GPIO but others to peripheral functions (or disabled). PTA2 on the KL02 defaults to SWD_DIO and so GPIO operatiosn will have no effect until its MUX setting is configured to a port.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The actual command is to write &lt;BR /&gt;&lt;STRONG&gt;PORTA_PCR2 = 0x00000100; // set GPIO on PTA2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beware that programming this pin to output will stop the debugger working....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;EM&gt;&lt;SPAN&gt;For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fsupport.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/support.html&lt;/A&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 13:45:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502782#M31522</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2018-09-13T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502783#M31523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've finally found the problem. In this MCU the PTA2 pin, when configured as output, is open drain (below an extract from the datasheet):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="PTA2 open drain.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/68669iF524735E055062FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="PTA2 open drain.jpg" alt="PTA2 open drain.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have to place an external pullup resistor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 14:17:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502783#M31523</guid>
      <dc:creator>btruden</dc:creator>
      <dc:date>2018-09-13T14:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502784#M31524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you had mentioned you were using a KE part and not the KE02 as in the thread I could have immediately told you than.&lt;/P&gt;&lt;P&gt;In the case of the KL02 there is also the same true-open-drain pins, but on PTB3 and PTB4 instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 15:03:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502784#M31524</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2018-09-13T15:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: MKL02Z PTA2(SWD_DIO) GPIO setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502785#M31525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, many replies...&lt;/P&gt;&lt;P&gt;sorry for late. i&amp;nbsp;have a&amp;nbsp;little issue&amp;nbsp;about&amp;nbsp;checking my email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anyway,&amp;nbsp;I think this is not exactly same problem with mine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, PTA2 pin&amp;nbsp;of KL02Z is basically SWD interface. This is essential function for develop this MCU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blas, accordingly your quoted in datasheet, Mark and You are totally right I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However in KL02Z, You need check and fix in startup code for some MCU setting.&lt;/P&gt;&lt;P&gt;- ex. NMI pin function, SWD pin setup, some memory protection...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My memory is very unclear but, in that time, I working with that and successfully use PTA2 as GPIO.&lt;BR /&gt;But some sample never recovered, cause SWD interface no longer available by my mistake.&lt;BR /&gt;After than, I fix my code, specific sequence&amp;nbsp; is added for enable SWD pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this tiny&amp;nbsp;little help for you guys. :smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a good day.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2018 00:52:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL02Z-PTA2-SWD-DIO-GPIO-setup/m-p/502785#M31525</guid>
      <dc:creator>OilCastle</dc:creator>
      <dc:date>2018-09-14T00:52:36Z</dc:date>
    </item>
  </channel>
</rss>

