大家好
我们正在开发一个系统、该系统需要 ADC 在比较器触发后的精确周期后启动转换。 这一次在我们中间是很小的。
为此、我们打算设置 Timer1.CC1以触发 ADC。 当 COMP (比较器)触发其中断时、定时器启动。 Timer 1.CC1‘“Form”(表单)信号如下所示:
_________________
_____| _________________________________
Dly | TRG 脉冲 |到下一个测量的延迟
由于计时器 CC1 (用于触发 ADC)有两个输出(一个 TB1.1A 至 P2.0、一个 TB1.1B 至 ADC)、因此我们已将另一个导向 P2.0 并测量示波器、以确保我们获得预期的正确波形。
因此、我们通过计时器的信号确认一切正常、但我们得到以下行为:
- ADC 仅触发一次、但看起来与脉冲的上升沿不同步
- ADC 始终保持繁忙状态。
其他注意事项包括:
- ADC 在定期软件启动(更改粗调触发源)时工作正常。
- 如果我们设置软件启动并且不进行软件触发、则 ADC 永远不会触发(如预期的那样)
- 改变正脉冲的长度没有什么不同
我担心的一个问题是 TB1.1A (测量值)与 TB1.1B 相同?
ADC 为何会保持忙碌?
ADC 设置代码如下:
此致
void InitialiseADCConverter(void)
{
ADCCTL0 &= ~ADCENC; // ADC Disabled to allow setup
ADCCTL0 = ADCSHT_2; // S&H=16 ADC clks
ADCCTL0 |= ADCON; // Turn ADC On
//ADCCTL0 |= ADCMSC; // Multiple conversions
ADCCTL1 = ADCSHS1; // Sample an hold trigger will come from Timer1 CCR1
ADCCTL1 |= ADCSHP; // Use the sampling Timer
// Default is no inversion (bit ADCISSH)
ADCCTL1 |= ADCDIV0; // We will divide the clock by 2 to get a 4MHz ADC clock (Max 6.6MHz for 10 bit)
ADCCTL1 |= ADCSSEL0 | ADCSSEL1; // Select the SMCLK (8MHz)
//Default is single channel Conversion (ADCCONSEQ0..1)
//No clock pre-scaler (ADCPDIV0.1)
ADCCTL2 |= ADCRES_1; // 10-bit conversion results
// Unsigned Binary result as default (ADCDF)
// ADC Buffer support 200Ksps as default(ADCSR)
ADCMCTL0 |= ADCSREF0; // Internal Reference
// Default input channel is 0 (ADCINCH0..3)
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
ADCCTL0 |= ADCENC; // Enable Conversions
//ADCCTL0 |= ADCSC // Start an ADC conversion
//Now we need to sort the reference or the ADC first start will be delayed
//whilst the ADC waits for the reference to be ready.
PMMCTL2 = 0; // this will be the 1.2V reference
PMMCTL2 |= REFBGEN | REFGEN; // Enable the Internal voltage references
PMMCTL2 |= TSENSOREN; // Enable the temperature sensor.
}
void InitialiseADCConverter(void)
{
ADCCTL0 &= ~ADCENC; // ADC Disabled to allow setup
ADCCTL0 = ADCSHT_2; // S&H=16 ADC clks
ADCCTL0 |= ADCON; // Turn ADC On
//ADCCTL0 |= ADCMSC; // Multiple conversions
ADCCTL1 = ADCSHS1; // Sample an hold trigger will come from Timer1 CCR1
ADCCTL1 |= ADCSHP; // Use the sampling Timer
// Default is no inversion (bit ADCISSH)
ADCCTL1 |= ADCDIV0; // We will divide the clock by 2 to get a 4MHz ADC clock (Max 6.6MHz for 10 bit)
ADCCTL1 |= ADCSSEL0 | ADCSSEL1; // Select the SMCLK (8MHz)
//Default is single channel Conversion (ADCCONSEQ0..1)
//No clock pre-scaler (ADCPDIV0.1)
ADCCTL2 |= ADCRES_1; // 10-bit conversion results
// Unsigned Binary result as default (ADCDF)
// ADC Buffer support 200Ksps as default(ADCSR)
ADCMCTL0 |= ADCSREF0; // Internal Reference
// Default input channel is 0 (ADCINCH0..3)
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
ADCCTL0 |= ADCENC; // Enable Conversions
//ADCCTL0 |= ADCSC // Start an ADC conversion
//Now we need to sort the reference or the ADC first start will be delayed
//whilst the ADC waits for the reference to be ready.
PMMCTL2 = 0; // this will be the 1.2V reference
PMMCTL2 |= REFBGEN | REFGEN; // Enable the Internal voltage references
PMMCTL2 |= TSENSOREN; // Enable the temperature sensor.
}