SLAA476B February 2011 – July 2019 BQ2040 , BQ2040 , BQ2060A , BQ2060A , BQ2063 , BQ2063 , BQ2083-V1P3 , BQ2083-V1P3 , BQ2084-V143 , BQ2084-V143 , BQ2084-V150 , BQ2084-V150 , BQ2085-V1P3 , BQ2085-V1P3 , BQ20Z40-R1 , BQ20Z40-R1 , BQ20Z70-V160 , BQ20Z70-V160 , BQ20Z80A-V110 , BQ20Z80A-V110 , BQ28400 , BQ28400 , BQ78PL114 , BQ78PL114 , BQ78PL116 , BQ78PL116 , LM5145 , LM5145 , MSP430F5500 , MSP430F5500 , MSP430F5501 , MSP430F5501 , MSP430F5502 , MSP430F5502 , MSP430F5503 , MSP430F5503 , MSP430F5504 , MSP430F5504 , MSP430F5505 , MSP430F5505 , MSP430F5506 , MSP430F5506 , MSP430F5507 , MSP430F5507 , MSP430F5508 , MSP430F5508 , MSP430F5509 , MSP430F5509 , MSP430F5510 , MSP430F5510 , TPS40057 , TPS40057 , TPS40170 , TPS40170
This function initializes the on-chip integrated 10-bit ADC to do single-channel single-conversions.
Function Definition
void ADC_Init(void) {...}
Inputs
None
Return
None
Example Function Call
ADC_Init();
The function uses a structure to map the MSP430F5510 port pins to the ADC channels and to also keep the assignments separated when multiple batteries are connected to the system.
Structure Definition Name
ADCDescription_t
Name | Type | Description | Example Value |
---|---|---|---|
BatteryNum | unsigned char | Value that represents battery channel number | BATT_1, BATT_2 |
ChannelType | unsigned char | Channel type (voltage or current) | CHANNEL_VOLTAGE, CHANNEL_CURRENT |
PortSelAddr | unsigned int | Address of the Port Select Register listed in the register description table of the data sheet. | P6SEL_ADDR |
PortBit | unsigned int | Bit of the port (value can range from 0 to 15) | BIT0, BIT1, ..., BITF |
InputChanNum | unsigned char | Value that represents ADC input channel number | ADC10INCH_1, ADC10INCH_2 |
Example Structure Declaration
For battery 1 voltage on P6.2 (A2) channel:
// Constant defined in header file
#define ADC_DEFAULT_STATE {BATT_1, CHANNEL_VOLTAGE, P6SEL_ADDR, BIT2, ADC10INCH_2}
// Declared in source code
ADCDescription_t ADC = ADC_DEFAULT_STATE;