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:需要找到斜坡的最小值和最大值

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/921296/ccs-tm4c123gh6pm-need-to-find-the-minimum-and-maximum-value-of-ramp

器件型号:TM4C123GH6PM

工具/软件:Code Composer Studio

大家好、

      我必须找到导通时间为400ms 的连续斜坡脉冲的最大值和最小值,并且必须将该最小值和最大值存储在500索引的数组中,任何人都能帮助我。 我从 ADC 和 comp 获取2个样本

#include 
#include 
include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/hw_gpio.h"
#include "driverlib/driver/hex/drivers/drivers/drivers/#include
"drivers/drivers/drivers.lib"



#drivers/drivers/drivers/htm#include "drivers/htm#drivers/htm#include "util.h"

#include "drivers/drivers/htm#include "drivers/drivers/htm#drivers/htm#include "drivers/htm#include "drivers/htm#include "drivers/htm#/htm#include "drivers/htm#include "drivers/htm#defintrl.lib.h







声明开始///////////////////////////////////////////////////////////////////////////////
const int sampleFreq = 150000、ref=2240;
uint32_t ADC0Value、Present、ADC[5]、AMP_ADC、max_ADC[500]、min_ADC[500]、System_Clock、Present、ADCsample、AMPLE_ADCsample;
uint16_t SamplePeriod、i;
uint32_t ui32Period、pcount=0、ncount=0、mutmaxvalue_adc、mutmaxvalue_adc、presminvalue_adc、adc_MaxValue、adc_Minool、min;
uint32_t l=0、k=0
、presminvalue_adc、separp;
bool max;
void systemsetup (void);
//void PWM_Enable (void);
void 计时器(void);
void ADC (void);
void Interrupt_Enable (void);
//////////////////////// 声明结束////////////////////////


void systemsetup (void)
{
SysCtlClockSet (SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHz|SYSCTL_OSC_MAIN);
MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB);
MAP_GPIOPinTypeGPIOOutput (GPIO_PORTB_BASE、GPIO_PIN_5);
MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、0);
System_Clock=SysCtlClockGet ();// 40MHz
STATUS=0;
最大值= 0;
nextsample=0;

}

void ADC0SS3IntHandler (void)
{

AST_ADCSAMPLE=Present ADCsample;
ROM_ADCSequenceDataGet (ADC0_BASE、3、ADC0Value);
ROM_ADCIntClear (ADC0_BASE、3);
if (max=0)
{
Prese_ADCsample=ADC0Value;
if (nextsample)
{
最大值= 1;
STATUS=1;

}
}
nextsample = 1;
if (状态)
{
if (Present (Present) ADCsample>Past (过去) ADCsample)
{
//前推 maxvalue_adc= maxpresvalue_adc;

maxpresevalue_adc=prese_adcsample;

// if (presmaxvalue_adc>premaxvalue_adc)
// {
ADC_MaxValue=presentmaxvalue_adc;
//}
AMPLE_ADCSAMPLE=0;
Prese_ADCsample=0;
nextsample = 0;
Max=0;

}
其他
{
//前推 minvalue_adc=presminvalue_adc;
presminvalue_adc=prese_adcsample;
// MIN=Present;ADCsample;
// if (presminvalue_adc 

挑战他们。 但我没有得到结果。

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

    您好 Gurpreet、

    脉冲可以产生的最高和最低电压是多少? 如果它们在3.3V 和0V 范围内、则 ADC 可能是您的最佳选择。

    我们可以帮助解决一般的器件问题、但大部分实施方案将由您决定。

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

    请回复、

    您能不能建议我没有获得输出,您能帮助我在我发布的代码中找到问题吗

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

    您好 Gurpreet、

    我可以在明天简要回顾一下您的代码是否有错误。 同时、如果您有 TivaWare 2.2.0、您还可以参考 外设/ADC 示例文件夹中的示例 ADC_UDMA_pingpong 以及 single_ended.c 示例、以与您的代码进行比较。

    确保您同时输入两个中断-快速浏览一下中断使能代码看起来不错、但这是您可以使用断点进行验证的内容。

    此外、您的 ADC ISR 看起来非常大。 您可能需要考虑将样本保存到数组中、并在脉冲经过时扫描应用程序中的最大值和最小值区域。

    您尚未回答电压范围问题、这一点很重要、因此我知道在工作时您会期望 ADC 值。

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

    您好 Gurpreet、

    我运行了您的代码、TM4C ADC 工作正常。 您似乎遇到了应用程序算法问题。

    我 总是会进入这条语句、因为 ALOW_ADCsample 始终为零。 您需要查看导致该问题的原因。 但就我所见、ADC 外设工作正常。

    if (prese_ADCsampl>ead_ADCsample)
    {
    //前言 maxvalue_adc= presemaxvalue_adc;
    
    maxpresvalue_adc=prese_adcsample;
    
    // if (presingmaxvalue_adc>premaxvalue_adc)
    // {
    ADC_MaxValue=presemaxvalue_adc;
    //}
    ALOW_ADCSAMPLE=0;
    Prese_ADCSAMPLE=0;
    nextSAMPLE=0;
    max=0;
    
    } 

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

    亲爱的泰纳克人  

    我的电压从200mV 到2.2V 不等。 我为同一问题编写了另一个代码。 仍然无法正常工作。 您能看到我的代码并建议修改吗

    #include 
    #include 
    include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_sysctl.h"
    #include "inc/hw_ints.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/driverlib.h"
    #driverlib_driver.h"
    
    
    
    
    
    #include "driverlib_drivers/driver.h"#include "driverlib#driverlib.md.htm#drivers/drivers.h"#include "driverlib#drivers/driverlib#drivers.h"#include "driverlib.md.util.h"#include "drivers.dlpinc/drivers.dlpintrinc/drivers.h"#include "drivers.dlpintrintrintrintrinc/drivers.h"#include "drivers.h"#drivers.dlpintr.md.dlpintr.md.dlpinc/drivers.h"#include "out.dlpintr.dlpinc/drivers.dlpintr.dlpinc/ude/drivers.dlpin
    
    
    
    
    
    
    
    
    void systemsetup (void);
    void ADCConfigure (void);
    
    void ADCConfigure()
    {
    
    // PK1与 ADC0配合使用//
    SysCtlPeripheralEnable (SYSCTL_Periph_ADC0);
    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);
    // PK2与 ADC1一起使用//
    
    }
    void systemsetup (void)
    {
    SysCtlClockSet (SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHz|SYSCTL_OSC_MAIN);
    MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB);
    MAP_GPIOPinTypeGPIOOutput (GPIO_PORTB_BASE、GPIO_PIN_5);
    MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、0);
    System_Clock=SysCtlClockGet ();// 40MHz
    
    
    }
    
    
    //**
    * main.c
    */
    int main (void)
    {
    systemsetup();
    ADCConfigure();
    ADCProcessorTrigger (ADC0_BASE、3);
    while (!ADCIntStatus (ADC0_BASE、3、false))
    {
    }
    
    ADCSequenceDataGet (ADC0_BASE、3、ADC0Value);
    ALOW_ADCSAMPLE=ADC0Value;
    ADCIntClear (ADC0_BASE、3);
    ADCProcessorTrigger (ADC0_BASE、3);
    while (!ADCIntStatus (ADC0_BASE、3、false))
    {
    }
    
    ADCSequenceDataGet (ADC0_BASE、3、ADC0Value);
    Prese_ADCsample=ADC0Value;
    ADCIntClear (ADC0_BASE、3);
    if (late_adCsample 100)
    {
    nCount=0;
    }
    // ADCSAMPLE=Present ADCsample;
    }
    
    
    }
    
    
    while (!ramp)
    {
    ALOW_ADCSAMPLE=Present ADCsample;
    ADCProcessorTrigger (ADC0_BASE、3);
    while (!ADCIntStatus (ADC0_BASE、3、false))
    {
    }
    ADCIntClear (ADC0_BASE、3);
    ADCSequenceDataGet (ADC0_BASE、3、ADC0Value);
    
    Prese_ADCsample=ADC0Value;
    if (PASE_ADCSAMPLE>Prese_ADCsample)(过去_ADCsample)
    {
    RAMP=0;
    
    
    }
    其他
    {
    斜坡= 1;
    min_adc[pcount]=page_adcsample;
    pcount++;
    if (pcount>100)
    {
    pcount=0;
    }
    //Past ADCsample=Present ADCsample;
    }
    
    
    }
    
    
    }
    

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

    您好 Gurpreet、

    如前所述、检索 ADC 结果的 TM4C 操作正常工作、但您的应用算法不正确。 我们在此不提供应用级帮助、仅提供特定于器件的帮助。 如果您认为问题与器件相关、请说明我如何重新创建您的问题、因为当我运行代码并进行调试时、我看到了正确的 ADC 值、但您的代码未正确存储它们、这超出了我们的范围、无法提供详细的帮助 (虽然我确实提到了我认为根本原因是什么)。

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

    感谢您的回复

     你能不能只是检查我发布的新代码,因为我被卡住了,没有任何线索。

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

    您好 Gurpreet、

    我再次检查、ADC 给出了预期结果、因此其配置正常。 您将需要调试自己的应用实现。