Hi friend,
I am using Q9021 with BLE SDK 1.0.0. How to enable brownout reset? What is the usage of BD_AMP_EN in PGCR2 register?
Thank you in advance.
Ted Wu
Hello @tedwu1
Hope you are doing well.
Registers that should cover Brownout Detector are:
PGCR2 (POWER_GATING_CTRL2)
Bit 5, BD_AMP_EN, 1 is Enable comparator of brown-out detector
ANALOG_CTRL
Bit 23-22, BD[1-0], Browned out detector threshold voltage selection
Bit 18, EN_BD, 1 is Enable browned out detector
For example, these functions should help you to enable Brown out detection:
// Enable comparator of brown-out detector
syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_BD_AMP_EN, MASK_ENABLE);
delay(10);
// Set Browned out detector threshold voltage to 1.6V
syscon_SetAnalogCRWithMask(QN_SYSCON, SYSCON_MASK_BD_TH, MASK_ENABLE);
// Enable browned out detector
syscon_SetAnalogCRWithMask(QN_SYSCON, SYSCON_MASK_BD_EN, MASK_ENABLE);
Regards,
Eduardo.
Thank you for your answer. I ported it to my code, but it always causes a nonstop reset. My code is as follows. Do you know why?
int main(void)
{
int ble_sleep_st, usr_sleep_st;
// DC-DC
dc_dc_enable(QN_DC_DC_ENABLE);
rf_tx_power_level_set (TX_GAIN_LEVLE12); // 4dbm
// QN platform initialization
#if QN_NVDS_WRITE
plf_init(QN_POWER_MODE, __XTAL, QN_32K_RCO, nvds_tmp_buf, NVDS_TMP_BUF_SIZE);
#else
plf_init(QN_POWER_MODE, __XTAL, QN_32K_RCO, NULL, 0);
#endif
#if (defined(QN_9020_B1) && (!QN_PMU_VOLTAGE))
disable_patch_b1();
#endif
// System initialization, user configuration
SystemInit();
// Enable comparator of brown-out detector
syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_BD_AMP_EN, MASK_ENABLE);
delay(10);
// Set Browned out detector threshold voltage to 1.6V
syscon_SetAnalogCRWithMask(QN_SYSCON, SYSCON_MASK_BD_TH, MASK_ENABLE);
// Enable browned out detector
syscon_SetAnalogCRWithMask(QN_SYSCON, SYSCON_MASK_BD_EN, MASK_ENABLE);
// Profiles register
#if (QN_WORK_MODE != WORK_MODE_HCI)
prf_register();
#endif
...
}
Best wishes
Ted Wu
Hi,
As libraries could have changed, I strongly recommend using the latest SDK available on the QN9020/21/22 website. Could you please try updating your SDK version?
Regards,
Eduardo.