<?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>Kinetis MicrocontrollersのトピックRe: MKL27Z64: Doubt about using PTA3 as GPIO</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287678#M60740</link>
    <description>&lt;P&gt;This is how i make it work, since i notice that operator |= as you say i was not getting what i expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;//ENCENDER PUERTO A&lt;/P&gt;&lt;P&gt;PORTA_PCR3 = 0x00000100; //&amp;nbsp;SWD_DIO&lt;/P&gt;&lt;P&gt;PORTA_PCR0 = 0x00000100; //&amp;nbsp;SWD_CLK&lt;/P&gt;&lt;P&gt;GPIOA_PDDR |= 1&amp;lt;&amp;lt;3;&lt;BR /&gt;GPIOA_PDDR |= 1&amp;lt;&amp;lt;0;&lt;/P&gt;&lt;P&gt;The only thing i changed was the assigment of PCR by manually writting the&amp;nbsp; value. Could you please tell me the reason that is not good practical the use of |=? What would you recommend to use instead.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jun 2021 18:02:21 GMT</pubDate>
    <dc:creator>RicardoRuiz18a</dc:creator>
    <dc:date>2021-06-04T18:02:21Z</dc:date>
    <item>
      <title>MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1267677#M60389</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I recently designed a test pcb for this MCU, the way i program the pcb is through USB port so i'm not using&amp;nbsp; the SWD port and have it disconnected, but i want/need to use this pin as GPIO it's default is SWD_DIO. The problem is when i configure that port to work as GPIO by writing '1' in the mux it just does not goes to 'o' logic i'm always getting high as output.&lt;/P&gt;&lt;P&gt;This is how i'm setting ports as outputs:&lt;/P&gt;&lt;P&gt;SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK// Turn on the port.&lt;BR /&gt;SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK&lt;/P&gt;&lt;P&gt;PORTB_PCR19 |= PORT_PCR_MUX(1);// select ALT 1 of mux (GPIO)&lt;BR /&gt;PORTB_PCR18 |= PORT_PCR_MUX(1);// 20&lt;BR /&gt;PORTA_PCR3 |= PORT_PCR_MUX(1);// 11&lt;/P&gt;&lt;P&gt;GPIOB_PDDR |= 1&amp;lt;&amp;lt;19;&lt;BR /&gt;GPIOB_PDDR |= 1&amp;lt;&amp;lt;18;&lt;BR /&gt;GPIOA_PDDR |= 1&amp;lt;&amp;lt;3;&lt;/P&gt;&lt;P&gt;Then in my program i use PSOR, PCOR, PTOR, PTB19 and PTB18 correctly change it's state, but PTA3 do nothing. I was thinking the reason for it is that this pin has an internal pullup resistor, but the reference manual does not give information about it.&lt;/P&gt;&lt;P&gt;It is possible to use this PTA3 as GPIO? Or which is the reason that i can't change the state to low?.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 17:42:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1267677#M60389</guid>
      <dc:creator>RicardoRuiz18a</dc:creator>
      <dc:date>2021-04-25T17:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1285995#M60693</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Please refer to reference manual.&amp;nbsp; &amp;nbsp;SWD_DIO is pulled up internally, should be disabled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielchen_0-1622623493959.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/146079i3ACFA755DD6CED7C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="danielchen_0-1622623493959.png" alt="danielchen_0-1622623493959.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 08:45:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1285995#M60693</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2021-06-02T08:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1286826#M60707</link>
      <description>&lt;P&gt;I regularly use the SWD CLK and DIO pins as outputs for debugging markers.&amp;nbsp;&lt;BR /&gt;The code is below, for GCC.&lt;BR /&gt;&lt;BR /&gt;Do not use the OR Assignment operator '|='&amp;nbsp;indiscriminately, despite NXP showing it in examples far to often.&amp;nbsp; At best it wastes code space and at worse you don't get what you expect for the register.&lt;BR /&gt;&lt;BR /&gt;/* Change bit to match your hardware, if needed: */&lt;BR /&gt;#define SWD_CLK_bp (0UL)&lt;BR /&gt;#define SWD_DIO_bp (3UL)&lt;/P&gt;&lt;P&gt;#define ATTR_NO_INSTRUMENT_FUNCTION __attribute__( ( no_instrument_function ) )&lt;/P&gt;&lt;P&gt;/* ---- */&lt;BR /&gt;#define SWD_CLK_bm (1UL &amp;lt;&amp;lt; SWD_CLK_bp)&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_CLK_ASSERT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PSOR = SWD_CLK_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_CLK_DEASSERT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PCOR = SWD_CLK_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_CLK_TOGGLE( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PTOR = SWD_CLK_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION uint8_t SWD_CLK_ASSERTED( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; return( 0U != (GPIOA_PDIR &amp;amp; SWD_CLK_bm) );&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION uint8_t SWD_CLK_DEASSERTED( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; return( 0U == (GPIOA_PDIR &amp;amp; SWD_CLK_bm) );&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_CLK_INIT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; PORTA_PCR0 = PORT_PCR_MUX( 1U );&lt;BR /&gt;&amp;nbsp; GPIOA_PCOR = SWD_CLK_bm;&lt;BR /&gt;&amp;nbsp; GPIOA_PDDR |= SWD_CLK_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* ---- */&lt;BR /&gt;#define SWD_DIO_bm (1UL &amp;lt;&amp;lt; SWD_DIO_bp)&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_DIO_ASSERT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PSOR = SWD_DIO_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_DIO_DEASSERT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PCOR = SWD_DIO_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_DIO_TOGGLE( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; GPIOA_PTOR = SWD_DIO_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION uint8_t SWD_DIO_ASSERTED( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; return( 0U != (GPIOA_PDIR &amp;amp; SWD_DIO_bm) );&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION uint8_t SWD_DIO_DEASSERTED( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; return( 0U == (GPIOA_PDIR &amp;amp; SWD_DIO_bm) );&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void SWD_DIO_INIT( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; PORTA_PCR3 = PORT_PCR_MUX( 1U );&lt;BR /&gt;&amp;nbsp; GPIOA_PCOR = SWD_DIO_bm;&lt;BR /&gt;&amp;nbsp; GPIOA_PDDR |= SWD_DIO_bm;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main( void )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SWD_CLK_INIT();&lt;BR /&gt;&amp;nbsp; SWD_DIO_INIT();&lt;/P&gt;&lt;P&gt;&amp;nbsp; SWD_DIO_TOGGLE(); /* Make DIO and CLK toggle out of phase */&lt;/P&gt;&lt;P&gt;for(;;)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp; SWD_CLK_TOGGLE();&lt;BR /&gt;&amp;nbsp; SWD_DIO_TOGGLE();&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 12:37:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1286826#M60707</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-06-03T12:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287678#M60740</link>
      <description>&lt;P&gt;This is how i make it work, since i notice that operator |= as you say i was not getting what i expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;//ENCENDER PUERTO A&lt;/P&gt;&lt;P&gt;PORTA_PCR3 = 0x00000100; //&amp;nbsp;SWD_DIO&lt;/P&gt;&lt;P&gt;PORTA_PCR0 = 0x00000100; //&amp;nbsp;SWD_CLK&lt;/P&gt;&lt;P&gt;GPIOA_PDDR |= 1&amp;lt;&amp;lt;3;&lt;BR /&gt;GPIOA_PDDR |= 1&amp;lt;&amp;lt;0;&lt;/P&gt;&lt;P&gt;The only thing i changed was the assigment of PCR by manually writting the&amp;nbsp; value. Could you please tell me the reason that is not good practical the use of |=? What would you recommend to use instead.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 18:02:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287678#M60740</guid>
      <dc:creator>RicardoRuiz18a</dc:creator>
      <dc:date>2021-06-04T18:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287721#M60742</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Could you please tell me the reason that is not good practical the use of |=?"&lt;BR /&gt;&lt;BR /&gt;The OR-assignment operator will first read the register, then OR in the constant, then write the new value back out to the register.&lt;BR /&gt;&lt;BR /&gt;In most cases this simply wastes a bit of time from the unneeded Read and OR.&lt;BR /&gt;It has the potential to increase code space, and this is device dependent.&lt;BR /&gt;&lt;BR /&gt;The two places that it can cause problems is that if a read of register, say a status register, causes some bit to change its value.&amp;nbsp; This could cause problems with lost bytes in a UART for example.&amp;nbsp; Again this is device dependent.&lt;BR /&gt;&lt;BR /&gt;In the case at hand here the state of the other bits in the register are unknown (unless you like reading datasheets in depth) and the Pull Up/Down bits could be enabled among&amp;nbsp;other bits. So it is better to use assignment ('=') to get the bits you want and ONLY the bits you want set.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 20:08:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287721#M60742</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-06-04T20:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287741#M60744</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/38376"&gt;@bobpaddock&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you expand on your comment "&lt;SPAN&gt;OR Assignment operator '|='&amp;nbsp;indiscriminately ...&amp;nbsp;at worse you don't get what you expect for the register.&lt;/SPAN&gt;"?&amp;nbsp;&lt;/P&gt;&lt;P&gt;What exactly are the issues (I haven't looked at the generated code and I'm wondering if what's generated is different in different situations).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should the statements be:&lt;/P&gt;&lt;PRE&gt;Register = Register | Constant;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Rather than:&lt;/P&gt;&lt;PRE&gt;Register |= Constant;&lt;/PRE&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 21:15:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1287741#M60744</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-06-04T21:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1288449#M60774</link>
      <description>&lt;P&gt;It is the difference between OR-Assignment vs Assignment that I'm referring too, rather than the two ways you explain of doing OR-Assignment.&lt;BR /&gt;&lt;BR /&gt;In the ARM line a lot of the registers are "Write '1' to clear" ('W1C' in the data sheets register notes) a bit in a status register.&lt;BR /&gt;&lt;BR /&gt;If a bit is already set and you are trying to clear a different bit by writing a '1' to it, that OTHER set bit gets cleared and lost.&amp;nbsp; This can make for hair pulling bugs where you end up with things that appear to be lost interrupts for example.&lt;BR /&gt;&lt;BR /&gt;In the case of this thread most of the pull-bits for PORTA are zero by default.&amp;nbsp; This particular bit is one by default, so using |= propagated the unwanted pull up.&lt;BR /&gt;&lt;BR /&gt;For reasons unknown to me Freescale/NXP uses |= in their examples when they really shouldn't.&amp;nbsp; Leading&amp;nbsp; many users to copy the examples as "the right way".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 17:36:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1288449#M60774</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-06-07T17:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: MKL27Z64: Doubt about using PTA3 as GPIO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1288479#M60776</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/38376"&gt;@bobpaddock&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gotcha - I haven't thought about that since 8 Bit days when input &amp;amp; output registers were paired to minimize address space issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would have thought the chance for that was designed out of (fairly new) processors like ARM.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx for taking the time to reply and explain.&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 17:35:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL27Z64-Doubt-about-using-PTA3-as-GPIO/m-p/1288479#M60776</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-06-07T17:35:59Z</dc:date>
    </item>
  </channel>
</rss>

