Configure the charging management module via menuconfig to use the built-in charging management of SF32L52, and drive it as shown below. You can set the charging current, but cannot set the full-charge voltage. Once the voltage reaches 4.2V, charging stops effectively, and the current drops to 6mA.
/**
* @brief Main program
* @param None
* @retval 0 if success, otherwise failure number
*/
int main(void)
{
rt_err_t charge_result;
// Initialize charger parameters
rt_kprintf("Initializing charger...\n");
// Set target charging voltage to 4.35V (4350mV)
charge_result = rt_charge_set_target_volt(4300);
if (charge_result != RT_CHARGE_EOK) {
rt_kprintf("Failed to set target voltage: %d\n", charge_result);
} else {
rt_kprintf("Target voltage set to 4.35V\n");
}
// Set charging current to 300mA
charge_result = rt_charge_set_cc_current(300);
if (charge_result != RT_CHARGE_EOK) {
rt_kprintf("Failed to set charge current: %d\n", charge_result);
} else {
rt_kprintf("Charge current set to 300mA\n");
}
// Set over-voltage protection to 4.6V (4600mV)
charge_result = rt_charge_set_over_volt(4600);
if (charge_result != RT_CHARGE_EOK) {
rt_kprintf("Failed to set over voltage: %d\n", charge_result);
} else {
rt_kprintf("Over voltage protection set to 4.6V\n");
}
// Enable charging
charge_result = rt_charge_enable(1);
if (charge_result != RT_CHARGE_EOK) {
rt_kprintf("Failed to enable charging: %d\n", charge_result);
} else {
rt_kprintf("Charging enabled\n");
}
while (1)
{
// ds_twr_responder();
rt_thread_mdelay(5000);
//rt_kprintf("__main loop__\r\n");
}
return RT_EOK;
}
I have already fixed an issue in the SDK, as shown in the image below:
However, the charging module still does not work properly. What could be the problem? The log output is as follows:

