使用Tiva C LaunchPad进行AD采样,主控MCU是TM4C123GH6PM,,开发环境为CCS5,使用的是官方例程,(1)不进行采样率配置的话数据是正常的,但是使用SysCtlADCSpeedGet()函数却发现得到的值为0,看资料上说不配置的话应该是有默认值的啊(2),因为在另外一个程序中需要设定采样率,但是一旦调用SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS)函数,在单步调试时程序就跳入了异常中断中去,下面是使用的程序,还望各位工程师能帮忙解决~感谢~
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"
#include "LCDDriver.h"
#include "math.h"
#include "driverlib/fpu.h"
void Show_LCD();
void Init_LCD_Show();
uint32_t ShowValue=0;
//*****************************************************************************
int main(void)
{
uint32_t pui32ADC0Value[1];
uint32_t ADCSpeed=0;//存储当前ADC采样速率
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
//SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS);//设置采样频率
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |
ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
Init_LCD_Show();
// FPUEnable();
// FPULazyStackingEnable();
while(1)
{
//
// Trigger the ADC conversion.
//
ADCProcessorTrigger(ADC0_BASE, 3);
//
// Wait for conversion to be completed.
//
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
//
// Clear the ADC interrupt flag.
//
ADCIntClear(ADC0_BASE, 3);
//
// Read ADC Value.
//
ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);
ShowValue=pui32ADC0Value[0]*3300/4096;
Show_LCD();
//获取当前ADC采样速率
ADCSpeed=SysCtlADCSpeedGet();
//
// This function provides a means of generating a constant length
// delay. The function delay (in cycles) = 3 * parameter. Delay
// 250ms arbitrarily.
//
SysCtlDelay(SysCtlClockGet() / 12);
}
}
xyz549040622:
SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS)
里面的参数应该是ADC0吧,是不是这里的问题