void CHG_Done_Current_Set(void)
{
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 0);
for(int itemp = 16; itemp > 1; itemp--); //延时5us左右
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 1);
}
When you need to adjust the cut-off current, first look at the code and SEPC
The setting method in the code is as above,
SPEC sets the cut-off current as follows:
To know the cut-off current, you need to know Ioreg
Look at SPEC for Ioreg settings.
Ioreg = 100mV/Rsns
Look at Rsns and find the schematic diagram
This is the SNS resistor R505 0.1R_1% of the current B project, but I asked about the 0.13 resistor used in the BOM
Then 0.13.
So this Iorge = 0.100v/0.13Ω = 769mA.
This current seems to be relatively large.
According to the current code, the cut-off current of 20%Iorge = 0.2 * 769 = 153mA is used
The current requirement is to set to 300mA, then try
30% Iorge = 0.3 * 769 = 230.7mA
40% Iorge = 0.4 * 769 = 307.6mA
50%Iorge = 0.5 * 769 = 384.5mA
So setting 40% Iorge is more appropriate.
The current setting is to first pull the CTRL pin low and then delay 5us before pulling it low
First use an oscilloscope to verify whether the delay between pin low and high is "optimized" because it is not written as volatile.
First measure with an oscilloscope
First measured with Delay (20ms), it turned out to be 20ms. accurate
Try this loop again with the default code, there is a problem here, because it is not volatile, I verified that this loop does not work with the waveform
Change this int type to volatile uint32_t type, set it to 100*1000 cycles, use an oscilloscope 1S to capture the waveform, and measure
100*1000 cycles correspond to 42ms, which is 42*1000us, which means that 1 cycle corresponds to 0.42us.
The default code turns out to be 16 cycles
Then 16*0.42us = 6.72us
Although it is recommended in SPEC to set the high and low level time to 2us (1-10us), it is more appropriate, but I still modify it according to the cycle of the mode
All set to 6.72us delay
/*
* 100 * 1000 -> (shi)42ms --> 42* 1000us
* 1->0.42us
*
*/
/*
* 低6.72us--->高6.72us--->低6.72us--->高6.72us--->低6.72us--->高
* 40%Ioreg
*/
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 0);
for(volatile uint32_t itemp = 16; itemp > 1; itemp--); //这个无所谓,默认的,是16*0.42 = 6.72us
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 1);
for(volatile uint32_t itemp = 16; itemp > 1; itemp--); //这个无所谓,默认的,是16*0.42 = 6.72us
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 0);
for(volatile uint32_t itemp = 16; itemp > 1; itemp--); //这个无所谓,默认的,是16*0.42 = 6.72us
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 1);
for(volatile uint32_t itemp = 16; itemp > 1; itemp--); //这个无所谓,默认的,是16*0.42 = 6.72us.
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 0);
for(volatile uint32_t itemp = 16; itemp > 1; itemp--); //这个无所谓,默认的,是16*0.42 = 6.72us
GPIO_PinModeSet(gpioPortC, CHG_CTRL_PIN, gpioModePushPull, 1);
OK, write the theoretical code according to SPEC OK.
The official current can be verified.
1: To verify whether the normal charging current is 769mA.
2: To verify whether the cut-off current is 307mA
ps, you can actually test if the resistance of the SNS is 0.13Ω first, haha
Come to verify on Monday