EasyManua.ls Logo

TELINK SEMICONDUCTOR TLSR8232 - Low Battery Voltage Alarm

Default Icon
211 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1 135 Ver.1.0.0
The “lowBattDet_tick” can be used to set frequency of battery detect. In the demo, the
period is set as 500ms by default, and it can be modified as needed.
Implementation of the “battery_power_check” involves details of battery detect
initialization, DFIFO setup, data acquisition and processing, as well as low voltage
alarming.
Complicated ADC usage and special HW limits may bring user difficulty in understanding.
It is highly recommended to follow the demo code as much as possible. Except a few
settings which is illustrated as modifiable in this document, DO NOT make any change.
DFIFO mode is used to acquire ADC result by sampling 8 times (default), removing the
maximum and minimum and calculating the average of 6 values. As shown in the
adc_vbat_init”, period for each sampling is 10.4us, so it takes 83us or so to get the
result.
In demo code, the macro “ADC_SAMPLE_NUMcan be changed to 4, so as to reduce
total ADC time to 41us. Sampling 8 times is recommended to get more accurate result. If
users modify the marco definition, the calculation of ADC should be modified accordingly.
The source code is:
u32 adcValueAvg = (adc_sample[2] + adc_sample[3] + adc_sample[4] +
adc_sample[5]) >> 2;
5.2.2.3 Low Battery Voltage Alarm
The parameter “minVol_mV” of the “battery_power_check” specifies secure or alarm
voltage in unit of mV. As explained earlier, default in the SDK is 2000 mV. In low battery
detect of main_loop, once supply voltage drops below 2000mV, MCU enters low voltage
range.
The following shows demo code to process low battery alarm. MCU must be shut down
once it enters low voltage range.
In “5316_ble_remote”, MCU can be shut down by entering deepsleep, and wake up by
key press.
Except mandatory MCU shutdown operation, users can modify other alarm behaviors.
In the code below, alarm indication is set as fast blinking for three times, reminding users
to recharge or replace battery.
if(vol < minVol_mV){
#if (1 && BLT_APP_LED_ENABLE) //led indicate
gpio_set_output_en(GPIO_LED, 1); //output enable
for(int k=0;k<3;k++){
gpio_write(GPIO_LED, 1);
sleep_us(200000);
gpio_write(GPIO_LED, 0);
sleep_us(200000);
}
gpio_set_output_en(GPIO_LED, 0);
#endif

Table of Contents