Part Number:TMS320F28379D
Tool/software: Code Composer Studio
I want to use CPU Timer to trigger AD sampling. The sampling frequency is set at 360kHz, so the frequency of CPU Timer is also set at 360kHz. In fact, the frequency of CPU Timer is not 360kHz, but 476kHz. If I reduce the sampling frequency (for example 100kHz), the CPU Timer can operate at the right frequency.
I want to know if the frequency of CPU Timer has a maximum range. If there is, the sampling frequency 360kHz exceeds this limit, I think the actual sampling frequency should be lower than 360kHz, not higher than 360kHz. And I want to know, How should I trigger the ADC to make the sampling frequency reach 360kHz?
void SetupCPUTimer0(void)
{
InitCpuTimers();
Sample=1000000/360000;
ConfigCpuTimer(&CpuTimer0, 180 ,Sample);
CpuTimer0Regs.TCR.all = 0x4000;
}
interrupt void cpu_timer0_isr(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
void ConfigureADC(void)
{
EALLOW;
AdcaRegs.ADCCTL2.bit.PRESCALE = 2;
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
DELAY_US(1000);
EDIS;
}
void SetupADCTimer0(Uint16 channel)
{
Uint16 acqps;
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
{
acqps = 14; //75ns
}
else //resolution is 16-bit
{
acqps = 63; //320ns
}
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel;
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps;
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //trigger on cputimer0
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
EDIS;
}
interrupt void adca1_isr(void)
{
float ADC_result=0;
ADC_result = (float)AdcaResultRegs.ADCRESULT0;
ADC_Result0[icount]=ADC_result;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}