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.

[参考译文] CCS/TM4C123GH6PM:TM4C123GH6PM ADC 触发器

Guru**** 2483995 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/729339/ccs-tm4c123gh6pm-tm4c123gh6pm-adc-trigger

器件型号:TM4C123GH6PM

工具/软件:Code Composer Studio

大家晚上好。

我在 TMC123GH6PM 上对 ADC 模块进行编程、我对触发 ADC 有一些疑问。
我的时钟系统为57MHz、我希望每1分钟触发一次 ADC。 为此,我加载时钟值 3428571428 (因为我使用32位计时器)。  
我的应用程序工作正常。

我的问题是:如何每10分钟触发一次?

我尝试使用预分频、但失败了。  预分频定时器不工作。 以下是我的代码:

//#define TimerOneShot //计时器单次触发仅可用于计时器两种
//#define TimerOneShotUp //计时器单次触发仅可用于 Timer16位

//############## --include 文件--#######
#include 
#include 
#include "inc/tm4c123gh6m.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h#"#driverlib/timer.h#/#include#/#"#/driverlib#/#"#"#.h"


--for Variable-#######
#define TimeTrigger 3428571428 //这意味着2^16
volatile uint32_t ui32MoistureBuffer[8]、ui32MoistureAvr、ui32Clock;
volatile float yot潮 气;


//######## --对于 ISR --######
void MOUSE_ISR (void)
{
ADCIntClear (ADC0_BASE、0);
ADCSequenceDataGet (ADC0_BASE、0、(uint32_t *)\ui32MoistureBuffer);
ui32MoistureAvr=(ui32MoistureBuffer[0]+ ui32MoistureBuffer[1]+ ui32MoistureBuffer[2]+ ui32MoistureBuffer[3]
+ ui32MoistureBuffer[4]+ ui32MoistureBuffer[5]+ ui32MoistureBuffer[6]+ ui32MoistureBuffer[7]+2)/8;
MoistureAvr*(5.0/4096.0);
ui32Clock++;
}


#if defined (TimerOneShot)|| Defined (TimerOneShotUp)
空 TimerActive (空)
{
#ifdef TimerOneShot
{
TimerLoadSet (TIMER0_BASE、TIMER_Both、19999999);
TimerEnable (TIMER0_BASE、TIMER_Both);
while (TimerValueGet (TIMER0_BASE、TIMER_Both)!=0)
{};
}
#endif

#ifdef TimerOneShotUp
空 TimerActive (空)
{
TimerLoadSet (TIMER0_BASE、TIMER_A、19999999);
TimerEnable (TIMER0_BASE、TIMER_A);
while (TimerValueGet (TIMER0_BASE、TIMER_A)!=0)
{};
}
#endif
}
#endif
int main (void)
{
/*时钟配置*/
SysCtlClockSet (SYSCTL_SYSDIV_3_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHz|SYSCTL_OSC_MAIN);
/*端口时钟配置*/
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);
SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0);
SysCtlPeripheralEnable (SYSCTL_Periph_ADC0);
//ADCHardwareOversampleConfigure (ADC0_BASE、64);
/*引脚配置*/
GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_2);
GPIOPinTypeADC (GPIO_Porte _BASE、GPIO_PIN_3);
/*ADC 配置*/
ADCSequenceConfigure (ADC0_BASE、0、ADC_TRIGGER_TIMER、0);
ADCSequenceStepConfigure (ADC0_BASE、0、0、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、1、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、2、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、3、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、4、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、5、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、6、ADC_CTL_CH0);
ADCSequenceStepConfigure (ADC0_BASE、0、7、ADC_CTL_CH0|ADC_CTL_IE| ADC_CTL_END);
ADCSequenceEnable (ADC0_BASE、0);
ADCIntEnable (ADC0_BASE、0);
IntEnable (INT_ADC0SS0);
IntMasterEnable();
/*定时器触发 ADC 配置*/
TimerConfigure (TIMER0_BASE、TIMER_CFG_PERIOD);
TimerPrescaleSet (TIMER0_BASE、TIMER_Both、60000);
TimerLoadSet (TIMER0_BASE、TIMER_Both、TimeTrigger);

TimerControlTrigger (TIMER0_BASE、TIMER_Both、TRUE);
TimerEnable (TIMER0_BASE、TIMER_Both);


#ifdef TimerOneShot
TimerConfigure (TIMER0_BASE、TIMER_CFG_A_ONE_SHOT);
#endif

#ifdef TimerOneShotUp
TimerConfigure (TIMER0_BASE、TIMER_CFG_A_ONE_SHOT_UP);
#endif


while (1)
{
//GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_2、4);
//ui32Clock=TimerValueGet (TIMER0_BASE、TIMER_Both);
//SysCtlDelay (20000000);
//ADCProcessorTrigger (ADC0_BASE、0);
}
}

此致、谢谢。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    标准定时器的预分频器只在16位模式下工作。 我建议您在64位模式下使用其中一个宽定时器。