<?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: NHS3152  - Measure resitance correct param ADC-I2D-DAC in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1162141#M42452</link>
    <description>&lt;P&gt;Hello Leo,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you adjust the parameters in&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Chip_I2D_Setup&lt;/FONT&gt;? Given your expected current at 100kOhm, you'll need to use the 25uA range, which corresponds to these parameters:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Chip_I2D_Setup(NSS_I2D, I2D_SINGLE_SHOT, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 100);&lt;/PRE&gt;
&lt;P&gt;See also &lt;EM&gt;Chapter 8&amp;nbsp;Current-to-Digital converter (I2D) &amp;gt; Specifications&lt;/EM&gt; in the datasheet.&lt;/P&gt;
&lt;P&gt;The conversion from&amp;nbsp;van pico Ampère to Ohm is then calculated as: &lt;FONT face="courier new,courier"&gt;resval = (adcInput_1 - adcInput_4) / (current_picoampere *&amp;nbsp;1e-12)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Let me know your results!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Best,&lt;BR /&gt;Dries.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Oct 2020 06:03:23 GMT</pubDate>
    <dc:creator>driesmoors</dc:creator>
    <dc:date>2020-10-02T06:03:23Z</dc:date>
    <item>
      <title>NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1161284#M42435</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create code following &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/109560"&gt;@driesmoors&lt;/a&gt;&amp;nbsp;' solution to &lt;A href="https://community.nxp.com/t5/NFC/Measure-resistance-NHS3152/m-p/831045" target="_self"&gt;Measure resitance: (NHS3152)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I have &lt;STRONG&gt;modified code&lt;/STRONG&gt; from the example:&amp;nbsp;&lt;STRONG&gt;mainndeft2t.c.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The program follows the following logic:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; 0.&amp;nbsp;&lt;/STRONG&gt;Wake up when NFC field is detected&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;STRONG&gt;from dries's answer)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;1. Set the configuration of the analog pins to IOCON_FUNC_&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;2. Connect the DAC to ANA1, set a continuous conversion of 1.25V (used: adcdac_nss_example_1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;3. Connect the I2D to ANA4, configure correctly and start a conversion. Only when&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a conversion is started, current will start flowing over your resistor. The current&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;will continue to flow when the conversion ends. -&amp;gt; a (used: i2d_nss_example_1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt; v4 (used: adcdac_nss_example_3)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;5. Connect the ADC to ANA1, and measure the voltage. -&amp;gt; v1&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(New insturcitons)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;6. R= V(V1-V2)/(I_pico * 10^-6)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;7. Display resitance value on screen phone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I connected a &lt;STRONG&gt;100KOHM resitor&lt;/STRONG&gt; between ana1 and ana4. The code runs but i am not getting a close resistor value. I get the following results:&amp;nbsp;&lt;/P&gt;&lt;P&gt;r=100[Kohm]&lt;/P&gt;&lt;P&gt;adc_1 = 1.34 [V]&lt;/P&gt;&lt;P&gt;adc_4 = 1.04 [V]&lt;/P&gt;&lt;P&gt;current_picoampere = 5*10^5 [pA]&lt;/P&gt;&lt;P&gt;which gives a low res = 0.3/0.5= 0.6 [Ohm]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have the following questions:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;EM&gt;How do i pass&amp;nbsp;1.25V ana1? (formula to convert the bits to ana value)&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Why am i getting current_picoampere = 5*10^5? is this too high?&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;What gain to i pass I2D for 100kOHM&lt;/STRONG&gt;, where can i find a table/formula to calculate this based on resistance ?&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;What errors are in the code that are giving me such a low res output ?&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/*
FROM https://community.nxp.com/t5/NFC/Measure-resistance-NHS3152/m-p/831045

1. Set the configuration of the analog pins to IOCON_FUNC_1
2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.
3. Connect the I2D to ANA4, configure correctly and start a conversion. Only when a conversion is started, current will start flowing over your resistor. The current will continue to flow when the conversion ends. -&amp;gt; a
4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt; v4
5. Connect the ADC to ANA1, and measure the voltage. -&amp;gt; v1

*/



/* ------------------------------------------------------------------------- */

#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt; // contains sprintf function (needs to be included to avoid : https://stackoverflow.com/questions/8440816/warning-implicit-declaration-of-function
#include "board.h"
#include "ndeft2t/ndeft2t.h"

/* ------------------------------------------------------------------------- */

#define LOCALE "en" /**&amp;lt; Language used when creating TEXT records. */
#define MIME "nhs31xx/example.ndef" /**&amp;lt; Mime type used when creating MIME records. */

/** The URL will be used in a single-record NDEF message. */
#define MAX_URI_PAYLOAD (254 - NDEFT2T_MSG_OVERHEAD(true, NDEFT2T_URI_RECORD_OVERHEAD(true)))
static const uint8_t sUrl[MAX_URI_PAYLOAD + 1 /* NUL */] = "nxp.com/NTAGSMARTSENSOR";

/**
 * The text and the MIME data are always presented together, in a dual-record NDEF message.
 * Payload length is split evenly between TEXT and MIME.
 */
#define MAX_TEXT_PAYLOAD (254 - (NDEFT2T_MSG_OVERHEAD(true, \
        NDEFT2T_TEXT_RECORD_OVERHEAD(true, sizeof(LOCALE) - 1) + \
        NDEFT2T_MIME_RECORD_OVERHEAD(true, sizeof(MIME) - 1)) / 2))
static uint8_t sText[MAX_TEXT_PAYLOAD] = "10 V1-V4";

/** @copydoc MAX_TEXT_PAYLOAD */
#define MAX_MIME_PAYLOAD MAX_TEXT_PAYLOAD
static uint8_t sBytes[MAX_MIME_PAYLOAD] = {0, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE};

/* ------------------------------------------------------------------------- */

/**
 * Used to determine which NDEF message must be generated.
 * - @c true: generate a single-record NDEF message containing a URL.
 * - @c false: generate a dual-record NDEF message containing a TEXT and a MIME record.
 */
static bool sState;

static volatile bool sButtonPressed = false; /** @c true when the WAKEUP button is pressed on the Demo PCB */
static volatile bool sMsgAvailable = false; /** @c true when a new NDEF message has been written by the tag reader. */
static volatile bool sFieldPresent = false; /** @c true when an NFC field is detected and the tag is selected. */

static void GenerateNdef_Url(void);
static void GenerateNdef_TextMime(void);
static void ParseNdef(void);

/* ------------------------------------------------------------------------- */

//Store adc_1, adc_4, current and resistance value
static volatile float adcInput_4 = 5.0;  // 4. store V input 4
static volatile float adcInput_1 = 5.0; //  5. store V input 1
static volatile int current_native; // 3. store I2D ana 4
static volatile int current_picoampere; // 3. store I2D ana4
static volatile double resval = -1; // store resistance calculated:  (dcInput_1-adcInput_4)/Current_picoampere*10e-6

static void adcdac_nss_example_1(void); //continuous DAC ana1
static void i2d_nss_example_1(void); //I2D ana4
static void adcdac_nss_example_3(void); //NEW single shot get ADC value ana4
static void adcdac_nss_example_3_2(void); //NEW single shot get ADC value ana1


/**
 * Handler for PIO0_0 / WAKEUP pin.
 * Overrides the WEAK function in the startup module.
 */
void PIO0_IRQHandler(void)
{
    Chip_GPIO_ClearInts(NSS_GPIO, 0, 1);
    sButtonPressed = true; /* Handled in main loop */
}

/**
 * Called under interrupt.
 * @see NDEFT2T_FIELD_STATUS_CB
 * @see pNdeft2t_FieldStatus_Cb_t
 */
void App_FieldStatusCb(bool status)
{
    if (status) {
        LED_On(LED_RED);
    }
    else {
        LED_Off(LED_RED);
    }
    sFieldPresent = status; /* Handled in main loop */
}

/**
 * Called under interrupt.
 * @see NDEFT2T_MSG_AVAILABLE_CB
 * @see pNdeft2t_MsgAvailable_Cb_t
 */
void App_MsgAvailableCb(void)
{
    sMsgAvailable = true; /* Handled in main loop */
}

/* ------------------------------------------------------------------------- */

/** Generates a single-record NDEF message containing a URL, and copies it to the NFC shared memory. */
static void GenerateNdef_Url(void)
{
    uint8_t instance[NDEFT2T_INSTANCE_SIZE];
    uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];
    NDEFT2T_CREATE_RECORD_INFO_T recordInfo = {.pString = NULL /* don't care */,
                                               .shortRecord = true,
                                               .uriCode = 0x01 /* "http://www." */};
    NDEFT2T_CreateMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE, true);
    if (NDEFT2T_CreateUriRecord(instance, &amp;amp;recordInfo)) {
        if (NDEFT2T_WriteRecordPayload(instance, sUrl, (int)strlen((char *)sUrl))) {
            NDEFT2T_CommitRecord(instance);
        }
    }
    NDEFT2T_CommitMessage(instance); /* Copies the generated message to NFC shared memory. */
}

/** Generates a dual-record NDEF message containing a TEXT and a MIME record, and copies it to the NFC shared memory. */
static void GenerateNdef_TextMime(void)
{
    uint8_t instance[NDEFT2T_INSTANCE_SIZE];
    uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];
    NDEFT2T_CREATE_RECORD_INFO_T textRecordInfo = {.pString = (uint8_t *)"en" /* language code */,
                                                   .shortRecord = true,
                                                   .uriCode = 0 /* don't care */};
    NDEFT2T_CREATE_RECORD_INFO_T mimeRecordInfo = {.pString = (uint8_t *)MIME /* mime type */,
                                                   .shortRecord = true,
                                                   .uriCode = 0 /* don't care */};
    NDEFT2T_CreateMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE, true);
    if (NDEFT2T_CreateTextRecord(instance, &amp;amp;textRecordInfo)) {
        if (NDEFT2T_WriteRecordPayload(instance, sText, sizeof(sText) - 1 /* exclude NUL char */)) {
            NDEFT2T_CommitRecord(instance);
        }
    }
    if (NDEFT2T_CreateMimeRecord(instance, &amp;amp;mimeRecordInfo)) {
        if (NDEFT2T_WriteRecordPayload(instance, sBytes, sizeof(sBytes))) {
            NDEFT2T_CommitRecord(instance);
        }
    }
    NDEFT2T_CommitMessage(instance); /* Copies the generated message to NFC shared memory. */
}

/** Parses the NDEF message in the NFC shared memory, and copies the TEXT and MIME payloads. */
static void ParseNdef(void)
{
    uint8_t instance[NDEFT2T_INSTANCE_SIZE];
    uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];
    NDEFT2T_PARSE_RECORD_INFO_T recordInfo;
    int len = 0;
    uint8_t *pData = NULL;

    if (NDEFT2T_GetMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE)) {
        while (NDEFT2T_GetNextRecord(instance, &amp;amp;recordInfo) != false) {
            pData = (uint8_t *)NDEFT2T_GetRecordPayload(instance, &amp;amp;len);
            switch (recordInfo.type) {
                case NDEFT2T_RECORD_TYPE_TEXT:
                    if ((size_t)len &amp;lt;= MAX_TEXT_PAYLOAD) {
                        memcpy(sText, pData, (size_t)len);
                        memset(sText + len, 0, MAX_TEXT_PAYLOAD - (size_t)len);
                    }
                    break;
                case NDEFT2T_RECORD_TYPE_MIME:
                    if ((size_t)len &amp;lt;= MAX_MIME_PAYLOAD) {
                        memcpy(sBytes, pData, (size_t)len);
                        memset(sBytes + len, 0, MAX_MIME_PAYLOAD - (size_t)len);
                    }
                    break;
                default:
                    /* ignore */
                    break;
            }
        }
    }
}


// 1. Set the configuration of the analog pins to IOCON_FUNC_1
// 2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.

void adcdac_nss_example_1(void) // Modified IOCON_ANA0_0 --&amp;gt; IOCON_ANA0_1 &amp;amp; ADCDAC_IO_ANA0_0 --&amp;gt; ADCDAC_IO_ANA0_1
{
//! [adcdac_nss_example_1]
    Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_1, IOCON_FUNC_1); // IOCON_FUN_1
    Chip_ADCDAC_Init(NSS_ADCDAC0);
    Chip_ADCDAC_SetMuxDAC(NSS_ADCDAC0, ADCDAC_IO_ANA0_1);
    Chip_ADCDAC_SetModeDAC(NSS_ADCDAC0, ADCDAC_CONTINUOUS);
    Chip_ADCDAC_WriteOutputDAC(NSS_ADCDAC0, 3000);
//! [adcdac_nss_example_1]
}


/* ------------------------------------------------------------------------- */
// 3. Connect the I2D to ANA4, configure correctly and start a conversion. Only when a conversion is started, current will start flowing over your resistor. The current will continue to flow when the conversion ends. -&amp;gt; a

// FROM i2d_nss_example_1


void i2d_nss_example_1(void)
{
//! [i2d_nss_example_1]
    int i2dValue;
    int i2dNativeValue;
    Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_4, IOCON_FUNC_1); // IOCON_FUN_1
    Chip_I2D_Init(NSS_I2D);
    Chip_I2D_Setup(NSS_I2D, I2D_SINGLE_SHOT, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_HIGH, 100);
    Chip_I2D_SetMuxInput(NSS_I2D, I2D_INPUT_ANA0_4);
    Chip_I2D_Start(NSS_I2D);
    while (!(Chip_I2D_ReadStatus(NSS_I2D) &amp;amp; I2D_STATUS_CONVERSION_DONE)) {
        ; /* wait */
    }
    i2dNativeValue = Chip_I2D_GetValue(NSS_I2D);
    i2dValue = Chip_I2D_NativeToPicoAmpere(i2dNativeValue, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_HIGH, 100);
    Chip_I2D_DeInit(NSS_I2D);
//! [i2d_nss_example_1]

    current_native = i2dNativeValue;
    current_picoampere = i2dValue;
}

// 4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt; v4

//FROM Example 3 - Single-shot Analog-to-Digital Conversion without IRQ

// The conversion: adc_input_voltage = (native_value * 1.2V) / 2825 + 0.09V
void adcdac_nss_example_3(void) // Modifications:  IOCON_ANA0_5--&amp;gt; IOCON_ANA0_4 &amp;amp; converted adcinput_4= (adcInput_4 * 1.2) / 2825 + 0.09
{
//! [adcdac_nss_example_3]
    Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_4, IOCON_FUNC_1);
    //Chip_ADCDAC_Init(NSS_ADCDAC0);
    Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_4);
    Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);
    Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);
    Chip_ADCDAC_StartADC(NSS_ADCDAC0);

    while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) &amp;amp; ADCDAC_STATUS_ADC_DONE)) {
        ; /* Wait until measurement completes. For single-shot mode only! */
    }

    adcInput_4 = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
    adcInput_4= (adcInput_4 * 1.2) / 2825 + 0.09; // CONVERSION added line

//! [adcdac_nss_example_3]
}


void adcdac_nss_example_3_2(void) // Modifications:  IOCON_ANA0_5--&amp;gt; IOCON_ANA0_1 &amp;amp; converted adcinput_1= (adcInput_1 * 1.2) / 2825 + 0.09
{
//! [adcdac_nss_example_3]
    Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_1, IOCON_FUNC_1);
    //Chip_ADCDAC_Init(NSS_ADCDAC0);
    Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_1);
    Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);
    Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);
    Chip_ADCDAC_StartADC(NSS_ADCDAC0);

    while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) &amp;amp; ADCDAC_STATUS_ADC_DONE)) {
        ; /* Wait until measurement completes. For single-shot mode only! */
    }

    adcInput_1 = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
    adcInput_1= (adcInput_1 * 1.2) / 2825 + 0.09; // CONVERSION added line

//! [adcdac_nss_example_3]
}





// MAIN
int main(void)
{
	Board_Init();
	NDEFT2T_Init();
    NVIC_EnableIRQ(PIO0_IRQn); /* PIO0_IRQHandler is called when this interrupt fires. */
    Chip_GPIO_EnableInt(NSS_GPIO, 0, 1);


    // 	for ever,  WHILE field is detected: 2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.
    for (;;) {
    while (sFieldPresent) {

    // 2. Connect the DAC to ANA1  -output Voltage
    	adcdac_nss_example_1();
    // 3. Connect the I2D to ANA4, - read current ana4 through resistor
    	i2d_nss_example_1();
    // 4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt;v4
    	adcdac_nss_example_3();
    // 5. Connect the ADC to ANA1, and measure the voltage. -&amp;gt; v1
    	adcdac_nss_example_3_2();
    // generate the message only once per field???
    	GenerateNdef_TextMime();
    	resval = (adcInput_1-adcInput_4)/(current_picoampere * 10e-5); // (v1-v4)/(I4pico * 10^-6) V/I=R [V/A =ohm]
    	sprintf((char *)sText, "adc_1: %4.2f adc_4: %4.2f pA: %4.d res: %4.4f, nat: %4.d", adcInput_1, adcInput_4,current_picoampere, resval,current_native );//commented in from Thesis, changes payloadText to sText


    // attach message to be read
        if (sMsgAvailable) {
              sMsgAvailable = false;
              ParseNdef();
          }
    }

    Chip_PMU_PowerMode_EnterDeepSleep();
    }
    return 0;

}



&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. since the update to the community page with the subsequent series of emails for badges, all your emails have gone to spam - maybe this is happening to other clients of yours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 11:13:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1161284#M42435</guid>
      <dc:creator>leo94</dc:creator>
      <dc:date>2020-09-30T11:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1162141#M42452</link>
      <description>&lt;P&gt;Hello Leo,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you adjust the parameters in&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Chip_I2D_Setup&lt;/FONT&gt;? Given your expected current at 100kOhm, you'll need to use the 25uA range, which corresponds to these parameters:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Chip_I2D_Setup(NSS_I2D, I2D_SINGLE_SHOT, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 100);&lt;/PRE&gt;
&lt;P&gt;See also &lt;EM&gt;Chapter 8&amp;nbsp;Current-to-Digital converter (I2D) &amp;gt; Specifications&lt;/EM&gt; in the datasheet.&lt;/P&gt;
&lt;P&gt;The conversion from&amp;nbsp;van pico Ampère to Ohm is then calculated as: &lt;FONT face="courier new,courier"&gt;resval = (adcInput_1 - adcInput_4) / (current_picoampere *&amp;nbsp;1e-12)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Let me know your results!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Best,&lt;BR /&gt;Dries.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 06:03:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1162141#M42452</guid>
      <dc:creator>driesmoors</dc:creator>
      <dc:date>2020-10-02T06:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1162282#M42455</link>
      <description>&lt;P&gt;Hi Dries,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;I updated&amp;nbsp;Chip_I2D_Setup as suggested:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;225&lt;/STRONG&gt; Chip_I2D_Setup(NSS_I2D, I2D_SINGLE_SHOT, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 100);&lt;/PRE&gt;&lt;P&gt;and converted pico (this was emabrassing)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;306&lt;/STRONG&gt; resval = (adcInput_1 - adcInput_4) / (current_picoampere *&amp;nbsp;1e-12)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;i also changed output code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;307&lt;/STRONG&gt; sprintf((char *)sText, "adc_1: %6.2f adc_4: %6.2f current_picoampere: %8.d resistance: %e current_native: %6.d", adcInput_1, adcInput_4,current_picoampere, resval,current_native );&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I get the following output:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;adc_1:1.34 adc_4:0.58 current_picoampere:178980 resistance:4.241142e+06 current_native:8949&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;adc_1:1.34 adc_4:0.56 current_picoampere:179140 resistance:4.303748e+06 current_native: 8957&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;adc_1:1.34 adc_4:0.58 current_picoampere: 179220 resistance:4.249684e+06 current_native:8961&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Possible things that could be affecting results:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am running Debug--&amp;gt; resume connect via LPC-link 2. maybe running the code this way affects outcome?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I haven't connected anything to the GND pin of NHS3152 - only connection is ana1-resistor[100kOhm]-ana4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Possible conversion errors for V1, V4, I2D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;leo&lt;/P&gt;&lt;P&gt;FULL NEW CODE:&lt;/P&gt;&lt;PRE&gt;/*&lt;BR /&gt;FROM https://community.nxp.com/t5/NFC/Measure-resistance-NHS3152/m-p/831045&lt;BR /&gt;&lt;BR /&gt;1. Set the configuration of the analog pins to IOCON_FUNC_1&lt;BR /&gt;2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.&lt;BR /&gt;3. Connect the I2D to ANA4, configure correctly and start a conversion. Only when a conversion is started, current will start flowing over your resistor. The current will continue to flow when the conversion ends. -&amp;gt; a&lt;BR /&gt;4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt; v4&lt;BR /&gt;5. Connect the ADC to ANA1, and measure the voltage. -&amp;gt; v1&lt;BR /&gt;&lt;BR /&gt;*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;&lt;BR /&gt;#include &amp;lt;string.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt; // contains sprintf function (needs to be included to avoid : https://stackoverflow.com/questions/8440816/warning-implicit-declaration-of-function&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#include "ndeft2t/ndeft2t.h"&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;&lt;BR /&gt;#define LOCALE "en" /**&amp;lt; Language used when creating TEXT records. */&lt;BR /&gt;#define MIME "nhs31xx/example.ndef" /**&amp;lt; Mime type used when creating MIME records. */&lt;BR /&gt;&lt;BR /&gt;/** The URL will be used in a single-record NDEF message. */&lt;BR /&gt;#define MAX_URI_PAYLOAD (254 - NDEFT2T_MSG_OVERHEAD(true, NDEFT2T_URI_RECORD_OVERHEAD(true)))&lt;BR /&gt;static const uint8_t sUrl[MAX_URI_PAYLOAD + 1 /* NUL */] = "nxp.com/NTAGSMARTSENSOR";&lt;BR /&gt;&lt;BR /&gt;/**&lt;BR /&gt;* The text and the MIME data are always presented together, in a dual-record NDEF message.&lt;BR /&gt;* Payload length is split evenly between TEXT and MIME.&lt;BR /&gt;*/&lt;BR /&gt;#define MAX_TEXT_PAYLOAD (254 - (NDEFT2T_MSG_OVERHEAD(true, \&lt;BR /&gt;NDEFT2T_TEXT_RECORD_OVERHEAD(true, sizeof(LOCALE) - 1) + \&lt;BR /&gt;NDEFT2T_MIME_RECORD_OVERHEAD(true, sizeof(MIME) - 1)) / 2))&lt;BR /&gt;static uint8_t sText[MAX_TEXT_PAYLOAD] = "10 V1-V4";&lt;BR /&gt;&lt;BR /&gt;/** @copydoc MAX_TEXT_PAYLOAD */&lt;BR /&gt;#define MAX_MIME_PAYLOAD MAX_TEXT_PAYLOAD&lt;BR /&gt;static uint8_t sBytes[MAX_MIME_PAYLOAD] = {0, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE};&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;&lt;BR /&gt;/**&lt;BR /&gt;* Used to determine which NDEF message must be generated.&lt;BR /&gt;* - @c true: generate a single-record NDEF message containing a URL.&lt;BR /&gt;* - @c false: generate a dual-record NDEF message containing a TEXT and a MIME record.&lt;BR /&gt;*/&lt;BR /&gt;static bool sState;&lt;BR /&gt;&lt;BR /&gt;static volatile bool sButtonPressed = false; /** @c true when the WAKEUP button is pressed on the Demo PCB */&lt;BR /&gt;static volatile bool sMsgAvailable = false; /** @c true when a new NDEF message has been written by the tag reader. */&lt;BR /&gt;static volatile bool sFieldPresent = false; /** @c true when an NFC field is detected and the tag is selected. */&lt;BR /&gt;&lt;BR /&gt;static void GenerateNdef_Url(void);&lt;BR /&gt;static void GenerateNdef_TextMime(void);&lt;BR /&gt;static void ParseNdef(void);&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;&lt;BR /&gt;//Store adc_1, adc_4, current and resistance value&lt;BR /&gt;static volatile float adcInput_4 = 5.0; // 4. store V input 4&lt;BR /&gt;static volatile float adcInput_1 = 5.0; // 5. store V input 1&lt;BR /&gt;static volatile int current_native; // 3. store I2D ana 4&lt;BR /&gt;static volatile int current_picoampere; // 3. store I2D ana4&lt;BR /&gt;static volatile double resval = -1; // store resistance calculated: (dcInput_1-adcInput_4)/Current_picoampere*10e-6&lt;BR /&gt;&lt;BR /&gt;static void adcdac_nss_example_1(void); //continuous DAC ana1&lt;BR /&gt;static void i2d_nss_example_1(void); //I2D ana4&lt;BR /&gt;static void adcdac_nss_example_3(void); //NEW single shot get ADC value ana4&lt;BR /&gt;static void adcdac_nss_example_3_2(void); //NEW single shot get ADC value ana1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/**&lt;BR /&gt;* Handler for PIO0_0 / WAKEUP pin.&lt;BR /&gt;* Overrides the WEAK function in the startup module.&lt;BR /&gt;*/&lt;BR /&gt;void PIO0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;Chip_GPIO_ClearInts(NSS_GPIO, 0, 1);&lt;BR /&gt;sButtonPressed = true; /* Handled in main loop */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/**&lt;BR /&gt;* Called under interrupt.&lt;BR /&gt;* @see NDEFT2T_FIELD_STATUS_CB&lt;BR /&gt;* @see pNdeft2t_FieldStatus_Cb_t&lt;BR /&gt;*/&lt;BR /&gt;void App_FieldStatusCb(bool status)&lt;BR /&gt;{&lt;BR /&gt;if (status) {&lt;BR /&gt;LED_On(LED_RED);&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;LED_Off(LED_RED);&lt;BR /&gt;}&lt;BR /&gt;sFieldPresent = status; /* Handled in main loop */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/**&lt;BR /&gt;* Called under interrupt.&lt;BR /&gt;* @see NDEFT2T_MSG_AVAILABLE_CB&lt;BR /&gt;* @see pNdeft2t_MsgAvailable_Cb_t&lt;BR /&gt;*/&lt;BR /&gt;void App_MsgAvailableCb(void)&lt;BR /&gt;{&lt;BR /&gt;sMsgAvailable = true; /* Handled in main loop */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;&lt;BR /&gt;/** Generates a single-record NDEF message containing a URL, and copies it to the NFC shared memory. */&lt;BR /&gt;static void GenerateNdef_Url(void)&lt;BR /&gt;{&lt;BR /&gt;uint8_t instance[NDEFT2T_INSTANCE_SIZE];&lt;BR /&gt;uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];&lt;BR /&gt;NDEFT2T_CREATE_RECORD_INFO_T recordInfo = {.pString = NULL /* don't care */,&lt;BR /&gt;.shortRecord = true,&lt;BR /&gt;.uriCode = 0x01 /* "http://www." */};&lt;BR /&gt;NDEFT2T_CreateMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE, true);&lt;BR /&gt;if (NDEFT2T_CreateUriRecord(instance, &amp;amp;recordInfo)) {&lt;BR /&gt;if (NDEFT2T_WriteRecordPayload(instance, sUrl, (int)strlen((char *)sUrl))) {&lt;BR /&gt;NDEFT2T_CommitRecord(instance);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;NDEFT2T_CommitMessage(instance); /* Copies the generated message to NFC shared memory. */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/** Generates a dual-record NDEF message containing a TEXT and a MIME record, and copies it to the NFC shared memory. */&lt;BR /&gt;static void GenerateNdef_TextMime(void)&lt;BR /&gt;{&lt;BR /&gt;uint8_t instance[NDEFT2T_INSTANCE_SIZE];&lt;BR /&gt;uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];&lt;BR /&gt;NDEFT2T_CREATE_RECORD_INFO_T textRecordInfo = {.pString = (uint8_t *)"en" /* language code */,&lt;BR /&gt;.shortRecord = true,&lt;BR /&gt;.uriCode = 0 /* don't care */};&lt;BR /&gt;NDEFT2T_CREATE_RECORD_INFO_T mimeRecordInfo = {.pString = (uint8_t *)MIME /* mime type */,&lt;BR /&gt;.shortRecord = true,&lt;BR /&gt;.uriCode = 0 /* don't care */};&lt;BR /&gt;NDEFT2T_CreateMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE, true);&lt;BR /&gt;if (NDEFT2T_CreateTextRecord(instance, &amp;amp;textRecordInfo)) {&lt;BR /&gt;if (NDEFT2T_WriteRecordPayload(instance, sText, sizeof(sText) - 1 /* exclude NUL char */)) {&lt;BR /&gt;NDEFT2T_CommitRecord(instance);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;if (NDEFT2T_CreateMimeRecord(instance, &amp;amp;mimeRecordInfo)) {&lt;BR /&gt;if (NDEFT2T_WriteRecordPayload(instance, sBytes, sizeof(sBytes))) {&lt;BR /&gt;NDEFT2T_CommitRecord(instance);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;NDEFT2T_CommitMessage(instance); /* Copies the generated message to NFC shared memory. */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/** Parses the NDEF message in the NFC shared memory, and copies the TEXT and MIME payloads. */&lt;BR /&gt;static void ParseNdef(void)&lt;BR /&gt;{&lt;BR /&gt;uint8_t instance[NDEFT2T_INSTANCE_SIZE];&lt;BR /&gt;uint8_t buffer[NFC_SHARED_MEM_BYTE_SIZE];&lt;BR /&gt;NDEFT2T_PARSE_RECORD_INFO_T recordInfo;&lt;BR /&gt;int len = 0;&lt;BR /&gt;uint8_t *pData = NULL;&lt;BR /&gt;&lt;BR /&gt;if (NDEFT2T_GetMessage(instance, buffer, NFC_SHARED_MEM_BYTE_SIZE)) {&lt;BR /&gt;while (NDEFT2T_GetNextRecord(instance, &amp;amp;recordInfo) != false) {&lt;BR /&gt;pData = (uint8_t *)NDEFT2T_GetRecordPayload(instance, &amp;amp;len);&lt;BR /&gt;switch (recordInfo.type) {&lt;BR /&gt;case NDEFT2T_RECORD_TYPE_TEXT:&lt;BR /&gt;if ((size_t)len &amp;lt;= MAX_TEXT_PAYLOAD) {&lt;BR /&gt;memcpy(sText, pData, (size_t)len);&lt;BR /&gt;memset(sText + len, 0, MAX_TEXT_PAYLOAD - (size_t)len);&lt;BR /&gt;}&lt;BR /&gt;break;&lt;BR /&gt;case NDEFT2T_RECORD_TYPE_MIME:&lt;BR /&gt;if ((size_t)len &amp;lt;= MAX_MIME_PAYLOAD) {&lt;BR /&gt;memcpy(sBytes, pData, (size_t)len);&lt;BR /&gt;memset(sBytes + len, 0, MAX_MIME_PAYLOAD - (size_t)len);&lt;BR /&gt;}&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;/* ignore */&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// 1. Set the configuration of the analog pins to IOCON_FUNC_1&lt;BR /&gt;// 2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.&lt;BR /&gt;&lt;BR /&gt;void adcdac_nss_example_1(void) // Modified IOCON_ANA0_0 --&amp;gt; IOCON_ANA0_1 &amp;amp; ADCDAC_IO_ANA0_0 --&amp;gt; ADCDAC_IO_ANA0_1&lt;BR /&gt;{&lt;BR /&gt;//! [adcdac_nss_example_1]&lt;BR /&gt;Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_1, IOCON_FUNC_1); // IOCON_FUN_1&lt;BR /&gt;Chip_ADCDAC_Init(NSS_ADCDAC0);&lt;BR /&gt;Chip_ADCDAC_SetMuxDAC(NSS_ADCDAC0, ADCDAC_IO_ANA0_1);&lt;BR /&gt;Chip_ADCDAC_SetModeDAC(NSS_ADCDAC0, ADCDAC_CONTINUOUS);&lt;BR /&gt;Chip_ADCDAC_WriteOutputDAC(NSS_ADCDAC0, 3000);&lt;BR /&gt;//! [adcdac_nss_example_1]&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* ------------------------------------------------------------------------- */&lt;BR /&gt;// 3. Connect the I2D to ANA4, configure correctly and start a conversion. Only when a conversion is started, current will start flowing over your resistor. The current will continue to flow when the conversion ends. -&amp;gt; a&lt;BR /&gt;&lt;BR /&gt;// FROM i2d_nss_example_1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void i2d_nss_example_1(void)&lt;BR /&gt;{&lt;BR /&gt;//! [i2d_nss_example_1]&lt;BR /&gt;int i2dValue;&lt;BR /&gt;int i2dNativeValue;&lt;BR /&gt;Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_4, IOCON_FUNC_1); // IOCON_FUN_1&lt;BR /&gt;Chip_I2D_Init(NSS_I2D);&lt;BR /&gt;Chip_I2D_Setup(NSS_I2D, I2D_SINGLE_SHOT, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 100);&lt;BR /&gt;Chip_I2D_SetMuxInput(NSS_I2D, I2D_INPUT_ANA0_4);&lt;BR /&gt;Chip_I2D_Start(NSS_I2D);&lt;BR /&gt;while (!(Chip_I2D_ReadStatus(NSS_I2D) &amp;amp; I2D_STATUS_CONVERSION_DONE)) {&lt;BR /&gt;; /* wait */&lt;BR /&gt;}&lt;BR /&gt;i2dNativeValue = Chip_I2D_GetValue(NSS_I2D);&lt;BR /&gt;i2dValue = Chip_I2D_NativeToPicoAmpere(i2dNativeValue, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_HIGH, 100);&lt;BR /&gt;Chip_I2D_DeInit(NSS_I2D);&lt;BR /&gt;//! [i2d_nss_example_1]&lt;BR /&gt;&lt;BR /&gt;current_native = i2dNativeValue;&lt;BR /&gt;current_picoampere = i2dValue;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// 4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt; v4&lt;BR /&gt;&lt;BR /&gt;//FROM Example 3 - Single-shot Analog-to-Digital Conversion without IRQ&lt;BR /&gt;&lt;BR /&gt;// The conversion: adc_input_voltage = (native_value * 1.2V) / 2825 + 0.09V&lt;BR /&gt;void adcdac_nss_example_3(void) // Modifications: IOCON_ANA0_5--&amp;gt; IOCON_ANA0_4 &amp;amp; converted adcinput_4= (adcInput_4 * 1.2) / 2825 + 0.09&lt;BR /&gt;{&lt;BR /&gt;//! [adcdac_nss_example_3]&lt;BR /&gt;Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_4, IOCON_FUNC_1);&lt;BR /&gt;//Chip_ADCDAC_Init(NSS_ADCDAC0);&lt;BR /&gt;Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_4);&lt;BR /&gt;Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);&lt;BR /&gt;Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);&lt;BR /&gt;Chip_ADCDAC_StartADC(NSS_ADCDAC0);&lt;BR /&gt;&lt;BR /&gt;while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) &amp;amp; ADCDAC_STATUS_ADC_DONE)) {&lt;BR /&gt;; /* Wait until measurement completes. For single-shot mode only! */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;adcInput_4 = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);&lt;BR /&gt;adcInput_4= (adcInput_4 * 1.2) / 2825 + 0.09; // CONVERSION added line&lt;BR /&gt;&lt;BR /&gt;//! [adcdac_nss_example_3]&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void adcdac_nss_example_3_2(void) // Modifications: IOCON_ANA0_5--&amp;gt; IOCON_ANA0_1 &amp;amp; converted adcinput_1= (adcInput_1 * 1.2) / 2825 + 0.09&lt;BR /&gt;{&lt;BR /&gt;//! [adcdac_nss_example_3]&lt;BR /&gt;Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_1, IOCON_FUNC_1);&lt;BR /&gt;//Chip_ADCDAC_Init(NSS_ADCDAC0);&lt;BR /&gt;Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_1);&lt;BR /&gt;Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);&lt;BR /&gt;Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);&lt;BR /&gt;Chip_ADCDAC_StartADC(NSS_ADCDAC0);&lt;BR /&gt;&lt;BR /&gt;while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) &amp;amp; ADCDAC_STATUS_ADC_DONE)) {&lt;BR /&gt;; /* Wait until measurement completes. For single-shot mode only! */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;adcInput_1 = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);&lt;BR /&gt;adcInput_1= (adcInput_1 * 1.2) / 2825 + 0.09; // CONVERSION added line&lt;BR /&gt;&lt;BR /&gt;//! [adcdac_nss_example_3]&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// MAIN&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;Board_Init();&lt;BR /&gt;NDEFT2T_Init();&lt;BR /&gt;NVIC_EnableIRQ(PIO0_IRQn); /* PIO0_IRQHandler is called when this interrupt fires. */&lt;BR /&gt;Chip_GPIO_EnableInt(NSS_GPIO, 0, 1);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// for ever, WHILE field is detected: 2. Connect the DAC to ANA1, set a continuous conversion of 1.25V.&lt;BR /&gt;for (;;) {&lt;BR /&gt;while (sFieldPresent) {&lt;BR /&gt;&lt;BR /&gt;// 2. Connect the DAC to ANA1 -output Voltage&lt;BR /&gt;adcdac_nss_example_1();&lt;BR /&gt;// 3. Connect the I2D to ANA4, - read current ana4 through resistor&lt;BR /&gt;i2d_nss_example_1();&lt;BR /&gt;// 4. Connect the ADC to ANA4, and measure the voltage. -&amp;gt;v4&lt;BR /&gt;adcdac_nss_example_3();&lt;BR /&gt;// 5. Connect the ADC to ANA1, and measure the voltage. -&amp;gt; v1&lt;BR /&gt;adcdac_nss_example_3_2();&lt;BR /&gt;// generate the message only once per field???&lt;BR /&gt;GenerateNdef_TextMime();&lt;BR /&gt;resval = (adcInput_1-adcInput_4)/(current_picoampere * 1e-12); // (v1-v4)/(I4pico * 1e-12) V/I=R [V/A =ohm]&lt;BR /&gt;sprintf((char *)sText, "adc_1: %6.2f adc_4: %6.2f current_picoampere: %8.d resistance: %e current_native: %6.d", adcInput_1, adcInput_4,current_picoampere, resval,current_native );//commented in from Thesis, changes payloadText to sText&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// attach message to be read&lt;BR /&gt;if (sMsgAvailable) {&lt;BR /&gt;sMsgAvailable = false;&lt;BR /&gt;ParseNdef();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Chip_PMU_PowerMode_EnterDeepSleep();&lt;BR /&gt;}&lt;BR /&gt;return 0;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 14:16:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1162282#M42455</guid>
      <dc:creator>leo94</dc:creator>
      <dc:date>2020-10-02T14:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1164434#M42500</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/109560"&gt;@driesmoors&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any update on why i am getting erroneous values for Resistance?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested for different resistances (1MOhm, 2Mohm, 3Mohm) and resistance measured is scaling correclty with resitance_real, but still not the correct value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leo&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 09:57:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1164434#M42500</guid>
      <dc:creator>leo94</dc:creator>
      <dc:date>2020-10-08T09:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1177420#M42774</link>
      <description>&lt;P&gt;Hi, is there no solution to this problem, or is it out of the scope of this community?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 16:08:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1177420#M42774</guid>
      <dc:creator>leo94</dc:creator>
      <dc:date>2020-11-03T16:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1369179#M46963</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/136045"&gt;@leo94&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the error in you code:&lt;/P&gt;&lt;P&gt;when you convert to pA in line 226 you used the Parameter: I2D_CONVERTER_GAIN_HIGH&lt;/P&gt;&lt;P&gt;while having the I2D configuered with the gain low ( Line 219)&lt;/P&gt;&lt;P&gt;I tried it with:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;i2dValue = Chip_I2D_NativeToPicoAmpere(i2dNativeValue, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 100);&lt;/LI-CODE&gt;&lt;P&gt;and got a resistor Value of rougly 97K using a 100k resistor&lt;/P&gt;&lt;P&gt;Best wishes,&lt;/P&gt;&lt;P&gt;Lennard&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 09:42:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1369179#M46963</guid>
      <dc:creator>l95kr</dc:creator>
      <dc:date>2021-11-10T09:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: NHS3152  - Measure resitance correct param ADC-I2D-DAC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1382550#M47285</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/193289"&gt;@l95kr&lt;/a&gt;, thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just verified it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 09:43:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/NHS3152-Measure-resitance-correct-param-ADC-I2D-DAC/m-p/1382550#M47285</guid>
      <dc:creator>leo94</dc:creator>
      <dc:date>2021-12-07T09:43:45Z</dc:date>
    </item>
  </channel>
</rss>

