<?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: QN9021 TX POWER 4dBm Battery Level Issue in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/QN9021-TX-POWER-4dBm-Battery-Level-Issue/m-p/1362629#M12266</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/171702"&gt;@wmtanada&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am not sure what is the specific issue that you have with the battery.&lt;/P&gt;
&lt;P&gt;Please look at the code below to calibrate the temperature sensor, that could help you with the calibration for the battery using the adc.&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;#include "analog.h"
#include "adc.h"
#include "nvds.h"

volatile uint32_t adc_done = 0;
static void adc_test_cb(void)
{
    adc_done = 1;
}

uint32_t temp_buf = 0;

void TEMP_sensor_calibration()
{
    adc_read_configuration read_cfg;

    temp_sensor_enable(MASK_ENABLE);
    int16_t tempv[100];
    adc_init(ADC_DIFF_WITH_BUF_DRV, ADC_CLK_1000000, ADC_INT_REF, ADC_12BIT);
    adc_done = 0;
    read_cfg.trig_src=ADC_TRIG_SOFT;
    read_cfg.mode = SINGLE_MOD;
    read_cfg.start_ch = TEMP;
    read_cfg.end_ch = TEMP;
		for(uint8_t i=0;i&amp;lt;100;i++)
		{
				adc_read(&amp;amp;read_cfg, tempv+i, 1, adc_test_cb);
//				printf("tempv:%x\r\n",tempv[i]);
				while (adc_done == 0);
		}
		for(uint8_t j=50;j&amp;lt;60;j++)
		{
			temp_buf += (tempv[j]&amp;amp;0xFFFF);
		}
		temp_buf /= 10;
		temp_buf |= 0xFFFF0000;
		printf("temp_buf:%x\r\n",temp_buf);
		
		nvds_put(NVDS_TAG_TEMPERATURE_OFFSET,NVDS_LEN_TEMPERATURE_OFFSET,(uint8_t *)&amp;amp;temp_buf);
				
		uint32_t temp_offset = 0;
		uint16_t nv_len = NVDS_LEN_TEMPERATURE_OFFSET;
		nvds_get(NVDS_TAG_TEMPERATURE_OFFSET,&amp;amp;nv_len,(uint8_t *)&amp;amp;temp_offset);
		TEMP_OFFSET = temp_offset;
		printf("temperature: %0.1f\r\n", (float)(TEMPERATURE_X10(tempv[0])/10.0));
		
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
    <pubDate>Wed, 27 Oct 2021 18:21:47 GMT</pubDate>
    <dc:creator>mario_castaneda</dc:creator>
    <dc:date>2021-10-27T18:21:47Z</dc:date>
    <item>
      <title>QN9021 TX POWER 4dBm Battery Level Issue</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9021-TX-POWER-4dBm-Battery-Level-Issue/m-p/1359939#M12244</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello and Good Day,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We have a working QN9021 project, and we have properly set the transmit power to 4dBm before the systemInit().&amp;nbsp; We would like to know how to calibrate the chip in order to get the right battery level reading.&amp;nbsp; No issues were encountered when the TX Power is set below 4dBm.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What procedure should we perform in order to have it working properly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope you could reply soon.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And, thank you very much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sincerely,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;William Ta&lt;/SPAN&gt;ñada&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 07:59:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9021-TX-POWER-4dBm-Battery-Level-Issue/m-p/1359939#M12244</guid>
      <dc:creator>wmtanada</dc:creator>
      <dc:date>2021-10-22T07:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: QN9021 TX POWER 4dBm Battery Level Issue</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9021-TX-POWER-4dBm-Battery-Level-Issue/m-p/1362629#M12266</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/171702"&gt;@wmtanada&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am not sure what is the specific issue that you have with the battery.&lt;/P&gt;
&lt;P&gt;Please look at the code below to calibrate the temperature sensor, that could help you with the calibration for the battery using the adc.&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;#include "analog.h"
#include "adc.h"
#include "nvds.h"

volatile uint32_t adc_done = 0;
static void adc_test_cb(void)
{
    adc_done = 1;
}

uint32_t temp_buf = 0;

void TEMP_sensor_calibration()
{
    adc_read_configuration read_cfg;

    temp_sensor_enable(MASK_ENABLE);
    int16_t tempv[100];
    adc_init(ADC_DIFF_WITH_BUF_DRV, ADC_CLK_1000000, ADC_INT_REF, ADC_12BIT);
    adc_done = 0;
    read_cfg.trig_src=ADC_TRIG_SOFT;
    read_cfg.mode = SINGLE_MOD;
    read_cfg.start_ch = TEMP;
    read_cfg.end_ch = TEMP;
		for(uint8_t i=0;i&amp;lt;100;i++)
		{
				adc_read(&amp;amp;read_cfg, tempv+i, 1, adc_test_cb);
//				printf("tempv:%x\r\n",tempv[i]);
				while (adc_done == 0);
		}
		for(uint8_t j=50;j&amp;lt;60;j++)
		{
			temp_buf += (tempv[j]&amp;amp;0xFFFF);
		}
		temp_buf /= 10;
		temp_buf |= 0xFFFF0000;
		printf("temp_buf:%x\r\n",temp_buf);
		
		nvds_put(NVDS_TAG_TEMPERATURE_OFFSET,NVDS_LEN_TEMPERATURE_OFFSET,(uint8_t *)&amp;amp;temp_buf);
				
		uint32_t temp_offset = 0;
		uint16_t nv_len = NVDS_LEN_TEMPERATURE_OFFSET;
		nvds_get(NVDS_TAG_TEMPERATURE_OFFSET,&amp;amp;nv_len,(uint8_t *)&amp;amp;temp_offset);
		TEMP_OFFSET = temp_offset;
		printf("temperature: %0.1f\r\n", (float)(TEMPERATURE_X10(tempv[0])/10.0));
		
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 18:21:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9021-TX-POWER-4dBm-Battery-Level-Issue/m-p/1362629#M12266</guid>
      <dc:creator>mario_castaneda</dc:creator>
      <dc:date>2021-10-27T18:21:47Z</dc:date>
    </item>
  </channel>
</rss>

