<?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 code interface for GPIO pin in S32K</title>
    <link>https://community.nxp.com/t5/S32K/code-interface-for-GPIO-pin/m-p/1508144#M17175</link>
    <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;Please help we with the following .&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#include "S32K144.h" /* include peripheral declarations S32K144 */

#define PTD16 16
#define PTC13 13

void WDOG_disable (void){
	WDOG-&amp;gt;CNT = 0xD928C520;
	WDOG-&amp;gt;TOVAL = 0x0000FFFF;
	WDOG-&amp;gt;CS = 0x00002100;
}

int main(void){
	int counter = 0;
	WDOG_disable();

	//Enable clocks to peripherals (Port Modules)
	PCC-&amp;gt;PCCn[PCC_PORTC_INDEX]=PCC_PCCn_CGC_MASK;
	PCC-&amp;gt;PCCn[PCC_PORTD_INDEX]=PCC_PCCn_CGC_MASK;

	//Configure port C12 as GPIO input (BTN 0 [SW2] on EVB)
	PTC-&amp;gt;PDDR &amp;amp;= ~(1&amp;lt;&amp;lt;PTC13);     /* Port C12: Data Direction= input (default) */
	PORTC-&amp;gt;PCR[13] = 0x00000110;  /* Port C12: MUX = GPIO, input filter enabled */

	// Configure port D0 as GPIO output (LED on EVB)
	PTD-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;PTD16;         /* Port D0: Data Direction= output */
	PORTD-&amp;gt;PCR[16] = 0x00000100;   /* Port D0: MUX = GPIO */

	for(;;) {
     if (PTC-&amp;gt;PDIR &amp;amp; (1&amp;lt;&amp;lt;PTC13))/* If Pad Data Input = 1 (BTN0 [SW3] pushed) */

     {
       PTD-&amp;gt; PCOR |= 1&amp;lt;&amp;lt;PTD16; /* Clear Output on port D0 (LED on) */
     }
     else

     { /* If BTN0 was not pushed */
       PTD-&amp;gt; PSOR |= 1&amp;lt;&amp;lt;PTD16; /* Set Output on port D0 (LED off) */
     }
    counter++;
    }


}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from the above code in the if ststement&lt;/P&gt;&lt;P&gt;if (PTC-&amp;gt;PDIR &amp;amp; (1&amp;lt;&amp;lt;PTC13))&amp;nbsp; /*If Pad Data Input = 1 (BTN0 [SW3] pushed) */&lt;/P&gt;&lt;P&gt;the above line represesnt that the button is pushed. how can i create a if condition if button is not pushed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (??????????????????) /* If Pad Data Input = 0 (BTN0[SW3] not pushed) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me fill up that space&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2022 08:59:23 GMT</pubDate>
    <dc:creator>akhilranga</dc:creator>
    <dc:date>2022-08-18T08:59:23Z</dc:date>
    <item>
      <title>code interface for GPIO pin</title>
      <link>https://community.nxp.com/t5/S32K/code-interface-for-GPIO-pin/m-p/1508144#M17175</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;Please help we with the following .&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#include "S32K144.h" /* include peripheral declarations S32K144 */

#define PTD16 16
#define PTC13 13

void WDOG_disable (void){
	WDOG-&amp;gt;CNT = 0xD928C520;
	WDOG-&amp;gt;TOVAL = 0x0000FFFF;
	WDOG-&amp;gt;CS = 0x00002100;
}

int main(void){
	int counter = 0;
	WDOG_disable();

	//Enable clocks to peripherals (Port Modules)
	PCC-&amp;gt;PCCn[PCC_PORTC_INDEX]=PCC_PCCn_CGC_MASK;
	PCC-&amp;gt;PCCn[PCC_PORTD_INDEX]=PCC_PCCn_CGC_MASK;

	//Configure port C12 as GPIO input (BTN 0 [SW2] on EVB)
	PTC-&amp;gt;PDDR &amp;amp;= ~(1&amp;lt;&amp;lt;PTC13);     /* Port C12: Data Direction= input (default) */
	PORTC-&amp;gt;PCR[13] = 0x00000110;  /* Port C12: MUX = GPIO, input filter enabled */

	// Configure port D0 as GPIO output (LED on EVB)
	PTD-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;PTD16;         /* Port D0: Data Direction= output */
	PORTD-&amp;gt;PCR[16] = 0x00000100;   /* Port D0: MUX = GPIO */

	for(;;) {
     if (PTC-&amp;gt;PDIR &amp;amp; (1&amp;lt;&amp;lt;PTC13))/* If Pad Data Input = 1 (BTN0 [SW3] pushed) */

     {
       PTD-&amp;gt; PCOR |= 1&amp;lt;&amp;lt;PTD16; /* Clear Output on port D0 (LED on) */
     }
     else

     { /* If BTN0 was not pushed */
       PTD-&amp;gt; PSOR |= 1&amp;lt;&amp;lt;PTD16; /* Set Output on port D0 (LED off) */
     }
    counter++;
    }


}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from the above code in the if ststement&lt;/P&gt;&lt;P&gt;if (PTC-&amp;gt;PDIR &amp;amp; (1&amp;lt;&amp;lt;PTC13))&amp;nbsp; /*If Pad Data Input = 1 (BTN0 [SW3] pushed) */&lt;/P&gt;&lt;P&gt;the above line represesnt that the button is pushed. how can i create a if condition if button is not pushed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (??????????????????) /* If Pad Data Input = 0 (BTN0[SW3] not pushed) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me fill up that space&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 08:59:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/code-interface-for-GPIO-pin/m-p/1508144#M17175</guid>
      <dc:creator>akhilranga</dc:creator>
      <dc:date>2022-08-18T08:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: code interface for GPIO pin</title>
      <link>https://community.nxp.com/t5/S32K/code-interface-for-GPIO-pin/m-p/1508613#M17195</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/203425"&gt;@akhilranga&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the first &lt;STRONG&gt;if&lt;/STRONG&gt; evaluates to false, it means that the button is not pressed and you can handle it with an &lt;STRONG&gt;else&lt;/STRONG&gt;. But if you need to see the state of the pin you can do it with the following line:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if (!(PTC-&amp;gt;PDIR &amp;amp; (1 &amp;lt;&amp;lt; PTC13))) /* If Pad Data Input = 0 (BTN0[SW3] not pushed) */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B.R.&lt;/P&gt;
&lt;P&gt;VaneB&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 07:24:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/code-interface-for-GPIO-pin/m-p/1508613#M17195</guid>
      <dc:creator>VaneB</dc:creator>
      <dc:date>2022-08-19T07:24:15Z</dc:date>
    </item>
  </channel>
</rss>

