Analog Subsystem Software
945
SPRUHE8E – October 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
Analog Subsystem
AnalogConfig1
1
Choose Analog Config Register 1 (used to read ADC1 clock status)
AnalogConfig2
2
Choose Analog Config Register 2 (used to read ADC2, COMP1,2,3,4,5,6 clock
status)
This function will return the status of the Analog Config Register 1 or 2 depending on the function
parameter used.
10.5.2 C28 Analog Subsystem Software Example
Below is a software example showing how to use all the C28 Analog Subsystem functions in an
application. The code initializes the Analog Subsystem and clock divider. It also enables ADC1, ADC2,
COMP1, and COMP4 analog peripherals. Lastly, the example reads the status of the Analog Subsystem
Config Registers to check for correctness.
unsigned short analoginit = 0;
unsigned short analogclock1 = 0;
unsigned short analogclock2 = 0;
analoginit = (**InitAnalogSystemClock)(ACLKDIV4);
// Initialize the Analog Subsystem and set the clock divider to divide by 4
EALLOW;
while((**AnalogClockEnable)(AnalogConfig1,ADC1_ENABLE));
// Enable ADC 1
while((**AnalogClockEnable)(AnalogConfig2,ADC2_ENABLE|COMP1_ENABLE|COMP4_ENABLE));
// Enable ADC 2, COMP1, and COMP4
analogclock1 = (**ReadAnalogClockStatus)(AnalogConfig1);
// Check Analog Config 1 Register for correct values (bit 3 should be set)
analogclock2 = (**ReadAnalogClockStatus)(AnalogConfig2);
// Check Analog Config 2 Register for correct values (bits 15,3,0 should be set)
EDIS;
NOTE:
Bits in the Analog Config 1 and 2 registers that are not defined by the AnalogClockMask
#define values are reserved.
NOTE:
The ReadAnalogClockStatus function must be used to check the correctness of the Analog
Config 1 and Analog Config 2 Registers if the header file functions (InitSysCtrl, InitAdc1, and
InitAdc2) are not used to enable ADC1 or ADC2.
10.5.3 M3 Analog Subsystem Functions
Three functions are defined in the sysctl.h file:
•
unsigned short AnalogClockEnable(unsigned short AnalogConfigReg, unsigned short
AnalogClockMask)
•
unsigned short AnalogClockDisable(unsigned short AnalogConfigReg, unsigned short
AnalogClockMask)
•
unsigned short ReadAnalogClockStatus(unsigned short AnalogConfigReg)
There are also #define values defined in the sysctl.h file which can be passed into the functions above.
10.5.3.1 AnalogClockEnable Function
The AnalogClockEnable function enables the clock to each Analog Subsystem peripheral. This function
requires two input parameters.
Valid #define values for the AnalogConfigReg parameter are located in the sysctl.h file.
AnalogConfig1
1
Choose Analog Config Register 1 (used to enable ADC1)
AnalogConfig2
2
Choose Analog Config Register 2 (used to enable ADC2, COMP1,2,3,4,5,6)
Valid #define values for the AnalogClockMask parameter are located in the sysctl.h file.