AN137 Silicon_Laboratories, AN137 Datasheet - Page 24

no-image

AN137

Manufacturer Part Number
AN137
Description
Lithium ION Battery Charger Using C8051f300
Manufacturer
Silicon_Laboratories
Datasheet
AN137
}
//-----------------------------------------------------------------------------
// Reset_Time_Base - Resets all Time Counting Values
//-----------------------------------------------------------------------------
void Reset_Time_Base()
{
}
//-----------------------------------------------------------------------------
// Delay - This is a Delay to permit time for Switches to Debounce
//-----------------------------------------------------------------------------
void Delay_Loop (void)
{
}
//-----------------------------------------------------------------------------
// Initialize CalibrateADCforVoltageMeasurement
//-----------------------------------------------------------------------------
// This function calibrates the voltage channel and stores the calibration
// coefficients in the parameters volt_slope and volt_offset.
//
void CalibrateADCforMeasurement()
// This calibration routine uses a 2 point cal.
{ unsigned char xdata *pwrite;
24
//Module 1
PCA0CPM1 = 0x49;
PCA0CPL1 = 0xFF;
PCA0CPH1 = 0x00;
EIE1
TIME.sec
TIME.min
TIME.hour
TIME.t_count = PWM_CLOCK;
long i=0;
for (i=0;i<100000;i++);
EA = 0;
// Wait until 1st calibration voltage is ready for cal
while (SW0 == 1);
Delay_Loop();
// Once ready, Get the first calibration voltage
AMX0SL = VBAT;
ADC0CF = (SYSCLK/5000000) << 3;
ADC0CF &=0xF8;
ADC0CF |= 0x01;
temp_INT_1.i = Measure();
// Wait until 2nd calibration voltage is ready for cal
while (SW0 == 1);
Delay_Loop();
= 0x08;
= 0x00;
= 0x00;
= 0x00;
// Configure Module 1 as software timer
// Initialize to 255 so that Interrupt
//
// 8-bit PWM Cycle
// PCA0CPH is the high byte of the
//
// Enable PCA Overflow Interrupt
// FLASH write pointer
// Disable All Interrupts
// Wait until SW0 pushed
// Wait for Switch Bounce
// Select appropriate input for AMUX
// ADC conversion clock = 5.0MHz
// Clear any Previous Gain Settings
// PGA gain = 1
// Wait until SW0 pushed
// Wait for Switch Bounce
Rev. 1.2
Output Compare Module
is generated when PCA ends

Related parts for AN137