<?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: adc interrupt in S32K</title>
    <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535780#M18231</link>
    <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/205701"&gt;@IuliaB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find this and more useful examples in the RTD development package.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can install it from its homepage at:&amp;nbsp;&lt;A href="https://www.nxp.com/design/automotive-software-and-tools/real-time-drivers-rtd:AUTOMOTIVE-RTD" target="_blank" rel="noopener"&gt;Real-Time Drivers (RTD) | NXP Semiconductors&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also, I'm attaching the example to this reply.&lt;/P&gt;
&lt;P&gt;Additionally, here is an example of how to use RTD drivers to create a simple project&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Create-a-Blinking-LED-example-project-using-S32K1xx-RTD/ta-p/1471810" target="_blank"&gt;HOWTO: Create a Blinking LED example project using... - NXP Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 16:52:08 GMT</pubDate>
    <dc:creator>JRoberto</dc:creator>
    <dc:date>2022-10-11T16:52:08Z</dc:date>
    <item>
      <title>adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1529492#M18033</link>
      <description>&lt;P&gt;Hello! Im&amp;nbsp; using an S32K144 board. I made a program where I light different colors on my led depending on the potentiometer value, but I did that in polling mode, where I wait until the conversion is done. I want to do it now by interrupts, but I'm not sure how to continue from this&lt;/P&gt;&lt;P&gt;ADC.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include "ADC.h"&lt;BR /&gt;uint32_t adcResultInmv=0;&lt;BR /&gt;uint32_t adcConvDone = 0;&lt;BR /&gt;void ADC_init(void) {&lt;/P&gt;&lt;P&gt;PCC-&amp;gt;PCCn[PCC_ADC0_INDEX] &amp;amp;=~ PCC_PCCn_CGC_MASK; /* Disable clock to change PCS */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_PCS(1); /* PCS=1: Select SOSCDIV2 */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_CGC_MASK; /* Enable bus clock in ADC */&lt;/P&gt;&lt;P&gt;ADC0-&amp;gt;SC1[0] = ADC_SC1_AIEN_MASK | /* AIEN=1: enable interrupt trigger */&lt;BR /&gt;ADC_SC1_ADCH(8); /* ADCH=8: serial number 0 selects channel 8 */&lt;BR /&gt;ADC0-&amp;gt;CFG1 = 0x000000004; /* ADICLK=0: Input clk=ALTCLK1=SOSCDIV2 */&lt;BR /&gt;/* ADIV=0: Prescaler=1 */&lt;BR /&gt;/* MODE=1: 12-bit conversion */&lt;BR /&gt;ADC0-&amp;gt;CFG2 = 0x00000000C; /* SMPLTS=12(default): sample time is 13 ADC clks */&lt;BR /&gt;ADC0-&amp;gt;SC2 = 0x00000000; /* ADTRG=0: SW trigger */&lt;BR /&gt;/* ACFE,ACFGT,ACREN=0: Compare func disabled */&lt;BR /&gt;/* DMAEN=0: DMA disabled */&lt;BR /&gt;/* REFSEL=0: Voltage reference pins= VREFH, VREEFL */&lt;BR /&gt;ADC0-&amp;gt;SC3 = 0x00000000; /* CAL=0: Do not start calibration sequence */&lt;BR /&gt;/* ADCO=0: One conversion performed */&lt;BR /&gt;/* AVGE,AVGS=0: HW average function disabled */&lt;BR /&gt;S32_NVIC-&amp;gt;ICPR[39 / 32] = (1 &amp;lt;&amp;lt; (39 % 32));&lt;BR /&gt;S32_NVIC-&amp;gt;ISER[39 / 32] = (1 &amp;lt;&amp;lt; (39 % 32));&lt;BR /&gt;S32_NVIC-&amp;gt;IP[39] = (10 &amp;lt;&amp;lt; 4);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void convertAdcChan(uint16_t adcChan) { /* For SW trigger mode, SC1[0] is used */&lt;BR /&gt;ADC0-&amp;gt;SC1[0]&amp;amp;=~ADC_SC1_ADCH_MASK; /* Clear prior ADCH bits */&lt;BR /&gt;ADC0-&amp;gt;SC1[0] = ADC_SC1_ADCH(adcChan); /* Initiate Conversion*/&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;uint8_t adc_complete(void) {&lt;BR /&gt;return ((ADC0-&amp;gt;SC1[0] &amp;amp; ADC_SC1_COCO_MASK)&amp;gt;&amp;gt;ADC_SC1_COCO_SHIFT); /* Wait for completion */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;uint32_t read_adc_chx(void) {&lt;BR /&gt;uint16_t adc_result=0;&lt;BR /&gt;adc_result=ADC0-&amp;gt;R[0]; /* For SW trigger mode, R[0] is used */&lt;BR /&gt;return (uint32_t) ((5000*adc_result)/0xFFF); /* Convert result to mv for 0-5V range */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void ADC0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;adcResultInmv = read_adc_chx();&lt;/P&gt;&lt;P&gt;adcConvDone = 1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main.c&lt;/P&gt;&lt;P&gt;#include "S32K144.h" /* include peripheral declarations S32K144 */&lt;BR /&gt;#include "clocks_and_modes.h"&lt;BR /&gt;#include "ADC.h"&lt;/P&gt;&lt;P&gt;#define PTC12 12 /* SW2*/&lt;BR /&gt;#define PTC13 13 /* SW3 */&lt;BR /&gt;#define PTD0 0 /*Blue LED*/&lt;BR /&gt;#define PTD15 15 /* Red LED */&lt;BR /&gt;#define PTD16 16 /* Green LED*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void PORT_init (void) {&lt;/P&gt;&lt;P&gt;PCC-&amp;gt;PCCn[PCC_PORTD_INDEX ]|=0x40000000; /* Enable clock for PORTD */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_PORTC_INDEX]=0x40000000; /* Enable clock for PORTC */&lt;/P&gt;&lt;P&gt;PORTD-&amp;gt;PCR[PTD0] = 0x00000100; /* Port D0: MUX = GPIO */&lt;BR /&gt;PORTD-&amp;gt;PCR[PTD15] = 0x00000100; /* Port D15: MUX = GPIO */&lt;BR /&gt;PORTD-&amp;gt;PCR[PTD16] = 0x00000100; /* Port D16: MUX = GPIO */&lt;/P&gt;&lt;P&gt;PTD-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;PTD0; /* Port D0: Data Direction= output */&lt;BR /&gt;PTD-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;PTD15; /* Port D15: Data Direction= output */&lt;BR /&gt;PTD-&amp;gt;PDDR |= 1&amp;lt;&amp;lt;PTD16; /* Port D16: Data Direction= output */&lt;/P&gt;&lt;P&gt;PTC-&amp;gt;PDDR =0; /* PTC: Data Direction= input */&lt;BR /&gt;PORTC-&amp;gt;PCR[12] = 0x00000110; /*Port C12: MUX = GPIO */&lt;BR /&gt;PORTC-&amp;gt;PCR[13] = 0x00000110; /*Port C13: MUX = GPIO */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void WDOG_disable (void){&lt;/P&gt;&lt;P&gt;WDOG-&amp;gt;CNT=0xD928C520; /* Unlock watchdog */&lt;BR /&gt;WDOG-&amp;gt;TOVAL=0x0000FFFF; /* Maximum timeout value */&lt;BR /&gt;WDOG-&amp;gt;CS = 0x00002100; /* Disable watchdog */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;uint32_t adcResultInMv=0;&lt;/P&gt;&lt;P&gt;WDOG_disable(); /* Disable WDOG*/&lt;BR /&gt;SOSC_init_8MHz(); /* Initialize system oscillator for 8 MHz xtal */&lt;BR /&gt;SPLL_init_160MHz(); /* Initialize SPLL to 160 MHz with 8 MHz SOSC */&lt;BR /&gt;NormalRUNmode_80MHz(); /* Init clocks: 80 MHz sysclk &amp;amp; core, 40 MHz bus, 20 MHz flash */&lt;BR /&gt;PORT_init(); /* Init port clocks and gpio outputs */&lt;BR /&gt;ADC_init(); /* Init ADC resolution 12 bit*/&lt;/P&gt;&lt;P&gt;for(;;)&lt;BR /&gt;{&lt;BR /&gt;convertAdcChan(12); /* Convert Channel AD12 to pot on EVB */&lt;BR /&gt;/* while(adc_complete()==0){} */ /* Wait for conversion complete flag */&lt;BR /&gt;adcResultInMv = read_adc_chx(); /* Get channel's conversion results in mv */&lt;/P&gt;&lt;P&gt;if(PTC-&amp;gt;PDIR &amp;amp; (1&amp;lt;&amp;lt;PTC13)) {&lt;BR /&gt;PTD-&amp;gt;PSOR |= 1&amp;lt;&amp;lt;PTD16;&lt;BR /&gt;PTD-&amp;gt; PCOR |= 1&amp;lt;&amp;lt;PTD15| 1&amp;lt;&amp;lt;PTD0;&lt;BR /&gt;}&lt;BR /&gt;else { /* If BTN0 was not pushed */&lt;BR /&gt;PTD-&amp;gt; PSOR |= 1&amp;lt;&amp;lt;PTD15| 1&amp;lt;&amp;lt;PTD0; /* Set Output on port D0 (LED off) */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if ((adcResultInMv &amp;gt; 3000)&amp;amp;&amp;amp;(adcResultInMv &amp;lt; 5000 )) { /* If 2.5 &amp;lt; result &amp;lt; 5V */&lt;BR /&gt;PTD-&amp;gt;PSOR |= 1&amp;lt;&amp;lt;PTD0 | 1&amp;lt;&amp;lt;PTD15; /* turn off blue, green LEDs */&lt;BR /&gt;PTD-&amp;gt;PCOR |= 1&amp;lt;&amp;lt;PTD16; /* turn on GREEN LED */&lt;BR /&gt;}&lt;BR /&gt;else if ((adcResultInMv &amp;gt;1500)&amp;amp;&amp;amp;(adcResultInMv &amp;lt;3000)) { /* If 1.5&amp;lt; result &amp;lt; 2.5V */&lt;BR /&gt;PTD-&amp;gt;PSOR |= 1&amp;lt;&amp;lt;PTD0 | 1&amp;lt;&amp;lt;PTD16; /* turn off blue, red LEDs */&lt;BR /&gt;PTD-&amp;gt;PCOR |= 1&amp;lt;&amp;lt;PTD15; /* turn on RED LED */&lt;BR /&gt;}&lt;BR /&gt;else if ((adcResultInMv &amp;gt;0)&amp;amp;&amp;amp;(adcResultInMv &amp;lt;1500)) { /* If 0 &amp;lt;result &amp;lt; 1.5V */&lt;BR /&gt;PTD-&amp;gt;PSOR |= 1&amp;lt;&amp;lt;PTD15 | 1&amp;lt;&amp;lt;PTD16; /* turn off red, green LEDs */&lt;BR /&gt;PTD-&amp;gt;PCOR |= 1&amp;lt;&amp;lt;PTD0; /* turn on BLUE LED */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;convertAdcChan(29); /* Convert chan 29, Vrefsh */&lt;BR /&gt;/* while(adc_complete()==0){} */ /* Wait for conversion complete flag */&lt;BR /&gt;adcResultInMv = read_adc_chx(); /* Get channel's conversion results in mv */&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 10:46:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1529492#M18033</guid>
      <dc:creator>IuliaB</dc:creator>
      <dc:date>2022-09-28T10:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1532888#M18129</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/205701"&gt;@IuliaB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I'm understanding correctly your question... you need information on how to configure the ADC interruption?&lt;/P&gt;
&lt;P&gt;Best Regards!.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 18:52:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1532888#M18129</guid>
      <dc:creator>JRoberto</dc:creator>
      <dc:date>2022-10-05T18:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1533125#M18133</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 05:08:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1533125#M18133</guid>
      <dc:creator>IuliaB</dc:creator>
      <dc:date>2022-10-06T05:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535107#M18209</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/205701"&gt;@IuliaB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I reviewed the RTD's example named&amp;nbsp;Adc_Pdb_Ip_example_S32K144 and I believe it contains the behavior you desire.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 20:55:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535107#M18209</guid>
      <dc:creator>JRoberto</dc:creator>
      <dc:date>2022-10-10T20:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535600#M18225</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/198240"&gt;@JRoberto&lt;/a&gt;&amp;nbsp;Im sorry but I dont know where to find it&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 11:22:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535600#M18225</guid>
      <dc:creator>IuliaB</dc:creator>
      <dc:date>2022-10-11T11:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: adc interrupt</title>
      <link>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535780#M18231</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/205701"&gt;@IuliaB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find this and more useful examples in the RTD development package.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can install it from its homepage at:&amp;nbsp;&lt;A href="https://www.nxp.com/design/automotive-software-and-tools/real-time-drivers-rtd:AUTOMOTIVE-RTD" target="_blank" rel="noopener"&gt;Real-Time Drivers (RTD) | NXP Semiconductors&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also, I'm attaching the example to this reply.&lt;/P&gt;
&lt;P&gt;Additionally, here is an example of how to use RTD drivers to create a simple project&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Create-a-Blinking-LED-example-project-using-S32K1xx-RTD/ta-p/1471810" target="_blank"&gt;HOWTO: Create a Blinking LED example project using... - NXP Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 16:52:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/adc-interrupt/m-p/1535780#M18231</guid>
      <dc:creator>JRoberto</dc:creator>
      <dc:date>2022-10-11T16:52:08Z</dc:date>
    </item>
  </channel>
</rss>

