QN9021 TX POWER 4dBm Battery Level Issue

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

QN9021 TX POWER 4dBm Battery Level Issue

520 Views
wmtanada
Contributor I

Hello and Good Day,

We have a working QN9021 project, and we have properly set the transmit power to 4dBm before the systemInit().  We would like to know how to calibrate the chip in order to get the right battery level reading.  No issues were encountered when the TX Power is set below 4dBm.

What procedure should we perform in order to have it working properly?

Hope you could reply soon.

And, thank you very much.

Sincerely,

William Tañada

 

0 Kudos
1 Reply

485 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @wmtanada,

I am not sure what is the specific issue that you have with the battery.

Please look at the code below to calibrate the temperature sensor, that could help you with the calibration for the battery using the adc.

#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<100;i++)
		{
				adc_read(&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<60;j++)
		{
			temp_buf += (tempv[j]&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 *)&temp_buf);
				
		uint32_t temp_offset = 0;
		uint16_t nv_len = NVDS_LEN_TEMPERATURE_OFFSET;
		nvds_get(NVDS_TAG_TEMPERATURE_OFFSET,&nv_len,(uint8_t *)&temp_offset);
		TEMP_OFFSET = temp_offset;
		printf("temperature: %0.1f\r\n", (float)(TEMPERATURE_X10(tempv[0])/10.0));
		
}

 

Regards,

Mario

0 Kudos