This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049: Calling SysCtl_deviceCal()

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Hello,

I want to know if I need to call the SysCtl_deviceCal when I run my debugger with a flash config. The documentation of the driver lib says:

#ifndef _FLASH
//
// Call Device_cal function when run using debugger
// This function is called as part of the Boot code. The function is called
// in the Device_init function since during debug time resets, the boot code
// will not be executed and the gel script will reinitialize all the
// registers and the calibrated values will be lost.
// Sysctl_deviceCal is a wrapper function for Device_Cal
//
SysCtl_deviceCal();
#endif

But in a flash config _FLASH is defined, which is a little bit misleading and should probably set to the DEBUG?

Furthermore, I looked into the gel script containg:

OnFileLoaded(int nErrorCode, int bSymbolsOnly)
{
if (!bSymbolsOnly) {
Device_Cal();
}

}

Which again lead me to the question, is it called or not? When debugging and checking the differences between not calling and calling SysCtl_deviceCal _cal, I experienced following behavior:

If I call  SysCtl_deviceCal(), ADCOFFTRIM is set. If I not call it, it is initially not set -> So it is not called.

But after starting my ADC modules after calliing the following c2000ware functions, the ADCCOFFTRIM register is set...


ADC_setVREF(…)
ADC_setPrescaler(ADCX_BASE, ADC_CLK_DIV_2_0);

ADC_setInterruptPulseMode(ADCX_BASE;ADC_PULSE_END_OF_CONV);
ADC_enableConverter(ADCX_BASE)

 

2) If I need to call it when using the debugger, is there any down side of always calling:

SysCtl_deviceCal();

3) After resetting the device, the calibration values should be loaded properly even with SysCtl_deviceCal(); commented out?

If this is the safe solution I would prefer to do it.

4) Technical Reference Manual (Rev. D) 13.11 ADC Calibration:

The boot ROM will call the calibration functions, so trim values should be initially populated without user intervention.

Where in the boot rom is it called? Could you tell me the line and the file?

Thanks in advance

  • Hi Jans,

    If debugger connection is detected upon device startup, there is a function in the gel file called "Device_Cal()" that automatically gets executed.  The problem is that the "Device_cal()" function in gel file is empty and once called, this causes the device calibration registers to be reset.  This is not the case when booting from flash (as long as the debugger is not connected/detected in the JTAG port) as the device calibration routine is called from bootrom.

    Bootrom symbols and source files are available as part of C2000Ware and can be found in libraries\boot_rom\f28004x.  cpubrom_boot.c shows the part where device calibration is called (line# 739).  Include file bootrom.h shows the address where device calibration routine is programmed in OTP during factory testing (line# 279).

    The device calibration routine residing in OTP sets a default ADCOFFSET value using external VREF mode.  There may be different ADC offset values depending on VREF mode (external/internal) or whether 2.5V/3.3V mode is chosen.  Since the VREF modes are not known upon bootup, the supplemental routines in ADC_setVREF() function will determine the correct ADC offset to apply since it is in this function where reference mode and reference voltage is chosen by the user.

    The function Sysctl_deviceCal_cal() is doing exactly what bootrom is doing by branching to the pointer to the device calibration routine residing in OTP (as described above).  Sysctl_deviceCal_cal() is only intended to be called when in debugger mode as that environment causes program execution to use the gel file and branch to an empty function that resets the calibration values.  There is no drawback in calling Sysctl_deviceCal_cal() multiple times but application really does not need to especially when booting up from flash as is the typical use case.

    Hope this clears your doubts with device calibration.  If not, let me know if you have additional questions/concerns.

    Best regards,

    Joseph 

  • Thank your for you detailed answer.