MCU-LINK as ISP/SWD with Flash Magic don't work for NHS3152

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCU-LINK as ISP/SWD with Flash Magic don't work for NHS3152

4,334 Views
waqar6414
Contributor II

Hello, I am attempting to flash the demo program (for resistance measuring) onto the NHS3152 soldered on a custom PCB using Flash Magic with MCU-LINK, but I am encountering issues during the flashing process by SWD and ISP modes. Below are the details of my problem.

NHS3152 soldered on PCB and connected to MCU-LINK by SWD probe (J6)

PCB-MCU-Link.jpg

The wiring of MCU-LINK (J6) to NHS3152 is as follows:

wiring.jpg

Flash magic screen settings:

Flash magic 1.bmp

Error details:

KakaoTalk_20250309_145831751.bmp

Power supply to NHS3152:

DMM.jpg

I tried to follow Arduino as ISP + Flash Magic don't work on NHS3152but it didn't work since the method relied on LPC-Link 2 instead of MCU-Link.

I would greatly appreciate it if you could look into my issue and assist me in resolving it. Thank you

 

Labels (1)
0 Kudos
Reply
10 Replies

3,804 Views
waqar6414
Contributor II

Hello,

I attempted to use the NHS3152 on a custom PCB, but was unsuccessful. As a result, I ordered the NHS3152DEMOADK and flashed the app_demo_tadherence.bin firmware via NFC.

My objective is to measure resistance using this setup. After flashing the demo application, I would like to understand how to proceed with resistance measurement. Specifically, do I need to develop a custom application using MCUXpresso, or is it possible to measure resistance directly by connecting the device under test to AN1 and AN4?

I would appreciate any guidance to help clarify this process. Thank you in advance for your support.

Best regards,

0 Kudos
Reply

3,778 Views
Daniel_Gutierrez
NXP Employee
NXP Employee

Hello @waqar6414, Good Day!

For measuring resistance with the NHS3152 a custom application is needed, as there is no dedicated example available in the SDK package. For implementing your own applications, I would recommend having a look at section 4 of the "UM11153" document available in "\release_mra2_12_6_nhs3152\docs" which describes the process for setting up a project for the NHS3152 in MCUXpresso IDE.

 

I would also recommend having a look at the ''\sw\nss\example_snippets'' folder in which you can find code examples on various peripherals for analog measurements. You may also find useful information on resistance measurement with the NHS3152 referring to this community thread: Solved: Re: Measure resistance: (NHS3152) - NXP Community.

 

My best regards,
Daniel.

0 Kudos
Reply

3,723 Views
waqar6414
Contributor II

Hello Daniel,

Thank you for your guidance. I was able to successfully create a program for resistance measurement without any errors. However, I am now encountering a persistent debugging error.

Initially, I was able to flash firmware (e.g., app_demo_dp_blinky) using LinkFlash without any issues. However, I am now consistently facing the same error, both in LinkFlash and MCUXpresso IDE. The pin connections remain unchanged and are connected correctly as before.

I would appreciate it if you could help me troubleshoot this issue. Please refer to the attached screenshot for more details on the error.

Best regards,

 

0 Kudos
Reply

3,698 Views
Daniel_Gutierrez
NXP Employee
NXP Employee

Hello @waqar6414, Good Day!

Please try selecting the "Wirespeed (Hz)" specifically. A speed of 4000 Hz has worked for me using the SWD protocol as well.

If you keep having trouble, please consider trying flashing with the "GUI Flash Tool" of MCUXpresso. Please refer to the configuration shown below.

 

 

Daniel_Gutierrez_1-1747676979039.png

 

In order to be able to flash the NHS3152 please make sure it is being correctly supplied with power using the battery.

 

My best regards,
Daniel.

0 Kudos
Reply

3,685 Views
waqar6414
Contributor II

Hello Daniel,

Thank you for your guidance as it worked well, and I was able to successfully flash my resistance measurement program to the chip.

However, the chip is currently reading an incorrect resistance value of approximately 25kΩ, while the actual connected resistor is 10kΩ. Could you please review the attached code to help identify where the issue might be? I’ve also included a screenshot of the resistance reading for reference.

Looking forward to your insights.

Best regards,

Resistance Code:


/*

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. -> a

4. Connect the ADC to ANA4, and measure the voltage. -> v4

5. Connect the ADC to ANA1, and measure the voltage. -> v1

 

*/

 

 

 

/* ------------------------------------------------------------------------- */

 

#include <string.h>

#include <stdlib.h>

#include <stdio.h> // 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" /**< Language used when creating TEXT records. */

#define MIME "nhs31xx/example.ndef" /**< 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, &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, &textRecordInfo)) {

if (NDEFT2T_WriteRecordPayload(instance, sText, sizeof(sText) - 1 /* exclude NUL char */)) {

NDEFT2T_CommitRecord(instance);

}

}

if (NDEFT2T_CreateMimeRecord(instance, &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, &recordInfo) != false) {

pData = (uint8_t *)NDEFT2T_GetRecordPayload(instance, &len);

switch (recordInfo.type) {

case NDEFT2T_RECORD_TYPE_TEXT:

if ((size_t)len <= 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 <= 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 --> IOCON_ANA0_1 & ADCDAC_IO_ANA0_0 --> 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. -> 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_LOW, 100);

Chip_I2D_SetMuxInput(NSS_I2D, I2D_INPUT_ANA0_4);

Chip_I2D_Start(NSS_I2D);

while (!(Chip_I2D_ReadStatus(NSS_I2D) & I2D_STATUS_CONVERSION_DONE)) {

; /* wait */

}

i2dNativeValue = Chip_I2D_GetValue(NSS_I2D);

i2dValue = Chip_I2D_NativeToPicoAmpere(i2dNativeValue, I2D_SCALER_GAIN_10_1, I2D_CONVERTER_GAIN_LOW, 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. -> 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--> IOCON_ANA0_4 & 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) & 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--> IOCON_ANA0_1 & 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) & 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();

// 2. Connect the DAC to ANA1 -output Voltage

adcdac_nss_example_1();

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) {

 

// 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. ->v4

adcdac_nss_example_3();

// 5. Connect the ADC to ANA1, and measure the voltage. -> v1

adcdac_nss_example_3_2();

// generate the message only once per field???

GenerateNdef_TextMime();

resval = (adcInput_1-adcInput_4)/(current_picoampere * 1e-12); // (v1-v4)/(I4pico * 1e-12) V/I=R [V/A =ohm]

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

 

 

// attach message to be read

if (sMsgAvailable) {

sMsgAvailable = false;

ParseNdef();

}

}

 

Chip_PMU_PowerMode_EnterDeepSleep();

}

return 0;

 

}

waqar6414_0-1747718353684.png

 

 
0 Kudos
Reply

3,631 Views
Daniel_Gutierrez
NXP Employee
NXP Employee

Hello @waqar6414 , Good Day!

 

As I can see on the picture you shared, the value obtained with the I2D peripheral (current) is exactly 25 uA  which would be the limit value of the corresponding range described in section 8 of the UM10876 document available in \release_mra2_12_6_nhs3152\docs. This happens because with a voltage of 1.33V (adc_1) and a 10k resistor, the current would be approximately 133 uA, which exceeds the limit of the range that has been set, so the returned value is the highest possible for that specific range.

 

Please refer to section 8.20 of the "NHS3152" document to find a detailed description on this matter, as well as some recommendations on combinations of resistors used with the different ranges of the I2D peripheral.

 

My best regards,
Daniel.

0 Kudos
Reply

4,297 Views
Daniel_Gutierrez
NXP Employee
NXP Employee

Hello @waqar6414, Good Day!

Thank you very much for your interest in our products.

The error you are getting is displayed when the Arm core could not be accessed, possible causes for this are:

 

  • The IC is not attached or not powered at all.
  • The IC has entered a low-power state, deep power-down state, or power-off state, where the SWD pins are no longer active.
  • The firmware image actively disables SWD access.

 

Please consider that when the firmware running in the NHS31xx IC decides to enter the deep power-down mode or the power-off mode, the SWD lines become inaccessible. Continuing or starting a debug session is then impossible. For addressing this problem and its solutions please refer to section 4.4 of the ''UM11153'' document, which can be found at ''C:\NHS31xx SDK Folder\docs\''.

 

Please make sure the chip is being correctly supplied with energy by checking pins:

VBAT(7) =  1.72 V to 3.6 V

VSS(8) = GND

You may refer to section 5 of the ''UM10876'' to find out more about power management.

 

I would like to point out that I have noticed some differences between your SWD pin distribution of the MCU Link and the one that is proved to work for debugging, please refer to this community thread Design Considerations for Debug - NXP Community and make sure the pin distribution you use sticks to the one described in the note, in which you will also find recommendations on required pull-up / pull-down resistors for some of the SWD pins.

 

My best regards,
Daniel.

0 Kudos
Reply

4,182 Views
waqar6414
Contributor II

Hello, Thankyou for your response. I tried to follow your guidelines, but none of them have worked for me.

Also, I have just realized that my MCU-LINK is not detected by MCU Xpresso after updating to the latest version. Although it is detected in device manager, and I believe it might be the reason for not responding of NHS3152 to MCU-LINK.

here are the details:

Device Manager_MCU-LINK.pngMCU Xpresso.bmpLinkserver probe test.jpg

 

0 Kudos
Reply

4,153 Views
Daniel_Gutierrez
NXP Employee
NXP Employee

Hello @waqar6414, Good Day!

Please consider that the window in which you find the ''MCU is not selected'' legend corresponds to the pin configuration tool of the IDE, the available debug probes can be found when starting a debug session or when using the GUI Flash Tool.

Please refer at the ''AN12328'' document available at ''C:\NHS31xx SDK Folder\docs\'' in which you will find a description of these and other flashing methods for NHS31xx ICs.

 

My best regards,
Daniel.

0 Kudos
Reply

4,178 Views
waqar6414
Contributor II
The MCU-Xpresso is v24.12
0 Kudos
Reply