ADC Circuit
www.ti.com
458
SPRUI07–March 2020
Submit Documentation Feedback
Copyright © 2020, Texas Instruments Incorporated
Analog-to-Digital Converter (ADC)
7.2.5.1.1 ADC_Cal Assembly Routine Method
The following three steps describe how to call the ADC_cal routine from an application:
Step 1. Add the ADC_cal assembly function to your project. The source is included with
(C2000Ware). The following code shows the contents of the ADC_cal function. The values
0xAAAA and 0xBBBB are place holders. The actual values programmed by TI are device
specific.
;-----------------------------------------------
; This is the ADC cal routine. This routine is programmed
; into reserved memory by the factory. 0xAAAA and 0xBBBB
; are place holders. The actual values programmed by TI
; are device specific.
; The ADC clock must be enabled before calling
; this function.
;-----------------------------------------------
.def _ADC_cal
.asg "0x711C", ADCREFSEL_LOC
.sect ".adc_cal"
_ADC_cal
MOVW DP, #ADCREFSEL_LOC >> 6
MOV @28, #0xAAAA
MOV @29, #0xBBBB
LRETR
Step 2. Add the .adc_cal section to your linker command file using the following:
MEMORY
{
PAGE 0 :
...
ADC_CAL : origin = 0x380080, length = 0x000009
...
}
SECTIONS
{
...
.adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
...
}
Step 3. Call the ADC_cal function before using the ADC. The ADC clocks must be enabled before
making this call.
extern void ADC_cal(void);
...
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
ADC_cal();
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;
EDIS;
7.2.5.1.2 Pointer to-Function Method
Because the ADC_CAL() routine is already programmed to TI reserved OTP memory by the factory, it can
be called via a pointer to the function by using the following steps:
Step 1. Define ADC_Cal as a pointer to the programmed function in the OTP memory.
#define ADC_Cal (void (*) (void)) 0x380080
Step 2. Call the ADC_Cal() function.
... EALLOW; SysCtrlRegs.PCLKCR0.bit.ADCENCLK=1; (*ADC_Cal) ();
SysCTRLRegs.PCLKCR0.bit.ADCENCLK=0; EDIS;