Hi all,
For my project, I would like to use DSP28x_usDelay( unsigned long Count) as C function by using Macro & ASM file as specified by the TI for ADC delay function. Inorder to use macro, TI recommends to use ASM File DSP28x_usDelay.asm file to include in the project. But I would like to use the ASM as below. Any suggestion would be appreciated.?
Code: init_adc.c
#define ADC_usDELAY 5000L
#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
// DO NOT MODIFY THIS LINE.
//#define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)
// Prototype
extern void DSP28x_usDelay(unsigned long Count); // Delay loop
// ADC Init sample
void initAdc()
{
EALLOW; // Enable writing to the EALLOW protected areas
SysCtrlRegs.PCLKCR0.bit.ADCENCLK=1; // Enable ADC clock
// IMPORTANT
// The ADC_cal function, which copies the ADC calibration values from TI reserved
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
// following function MUST be called for the ADC to function according to specification.
// The clocks to the ADC MUST be enabled before calling this function.
// See the device data manual and/or the ADC Reference Manual for more information.
// ADC_cal(); // Is this handled else where in the code.
AdcRegs.ADCTRL3.all = 0x00E1; // Power up bandgap/reference/ADC circuits
DSP28x_usDelay(ADC_usDELAY); // Delay of 5 ms required before converting ADC channel
EDIS; // Disable writing to the EALLOW protected areas
}
// Delay Loop some thing like this:
void DSP28x_usDelay(unsigned long Count)
{
asm(".def _DSP28x_usDelay");
asm(".sect ramfuncs");
asm(".global __DSP28x_usDelay");
asm("_DSP28x_usDelay:");
asm(" SUB ACC,#1");
asm(" BF _DSP28x_usDelay,GEQ");
asm(" LRETR");
}
Regards,
Kuldeep