Using NHS3152 I am tyring to:
- Power on with NFC (battery free)
- Get V1, V2, I (voltages and current from pin 1 and 4)
- Calculate resistance Res = (V1-V2)/I
- Commit message "V1: V1value, V2: V2value, I: Ivalue, Res: ResValue
The code is working, however i cannot remove semihosting becuase i am using a sprintf (Link to question with dries comment )

I have the following questions:
1. Can you confirm that i cannot flash to NHS3152 due to sprintf ?
2. How do i commit a message that contains the values of the variables V1, V2, I, RES ?
I basically need to be able to disconnect the NHS3152 from hte LPCLINK, and still see my code running, but its been quite frustrating and everything i've tried hasn't worked, obviously i am not able to understand what the issue is.
@converse I am answering here since when i reply, it keeps telling me " Post flooding detected "
Thanks for the help,
So following on from This post I selected Quickstart --> set library/header --> redlibnohost. I then debugged and ran the code.
At this point when i bring the phone near the tag, The LED goes red and the message " adc_1: 0....." is displayed.
I then stopped debug and the message still updates normally every time i bring the tag in contact.

I disconnected the USB from the PC, now the tag RED LED lights up, but as previously NO message "Tag is empty or not alligned"
Below is extra information incase the issue isn't a simple fix:
Here I am assuming that the steps "Debug-->Resume-->stop Debug--> disconnect USB" Should allow the chip to have the program onboard, since it works with the blinky example ?
For reference i have included the main and the libraries my code (full code here)is using: I have commeted out
//Chip_PMU_PowerMode_EnterDeepSleep();
perhaps this causes an issue ?
The Libraries I imported:
#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"
// 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. ->v4
adcdac_nss_example_3();
// 5. Connect the ADC to ANA1, and measure the voltage. -> v1
adcdac_nss_example_3_2();
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
// generate the message only once per field???
GenerateNdef_TextMime();
}
//Chip_PMU_PowerMode_EnterDeepSleep();
}
return 0;
}
EDIT2: reply to @driesmoors :
Hi Driers,
I have modified loopx as you suggested, i am still running into the same problem: once i disconnect the USB from PC, "tag is empty or not alligned".
To store values in fixed memory, i have created these two following voids that i modified from : Example Read modify_ and write EEPROM content in the section eeprom: EEPROM driver
void Chip_reads_a_fixed_memory_location_in_EEPROM (void)
{
Chip_EEPROM_Init(NSS_EEPROM);
Chip_EEPROM_Read(NSS_EEPROM, 61, &sText, sizeof(sText-1));
Chip_EEPROM_DeInit(NSS_EEPROM);
}
void Chip_stores_values_in_fixed_memory_location_in_EEPROM (void)
{
Chip_EEPROM_Init(NSS_EEPROM);
Chip_EEPROM_Write(NSS_EEPROM, 61, &sText, sizeof(sText-1));
Chip_EEPROM_Flush(NSS_EEPROM, true);
Chip_EEPROM_DeInit(NSS_EEPROM);
}
Here is the code that i modified from the main, covering points 2-5 of your suggested loopx:
// 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. Chip reads a fixed memory location in EEPROM
Chip_reads_a_fixed_memory_location_in_EEPROM();
// 3. Chip creates and commits an NDEF message
GenerateNdef_TextMime();
// 4. Chip calculates sensors resistance R: V1, V2, I, and R= (V1-V2)/I
// 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. ->v4
adcdac_nss_example_3();
// 5. Connect the ADC to ANA1, and measure the voltage. -> v1
adcdac_nss_example_3_2();
resval = (adcInput_1-adcInput_4)/(current_picoampere * 1e-12); // (v1-v4)/(I4pico * 1e-12) V/I=R [V/A =ohm]
// 5. Chip stores values in fixed memory location in EEPROM
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 );
Chip_stores_values_in_fixed_memory_location_in_EEPROM();
GenerateNdef_TextMime();
}
}
return 0;
}
After debug-resume --> message is updating correctly
Stop --> message still updating correclty
Remove USB --> tag is empty or not alligned