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/MSP432E411Y:ADC Thread 是否可用?

Guru**** 2589245 points
Other Parts Discussed in Thread: MSP432E411Y

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/948037/ccs-msp432e411y-is-adc-thread-available

器件型号:MSP432E411Y

工具/软件:Code Composer Studio

感谢您始终友好地回答我的问题。

我尝试不是连续而是非连续使用 ADC 引脚。

因此、我编写了参考示例代码的 ADC 信号通道的代码。

ADC0和 ADC1线程被创建并且每个线程接收数据100次。

我猜是 ADC0、ADC1将使用交替函数运行、但 ADC0将运行100次、ADC1将运行100次。

此外、定时器也被置位、但是定时器在功能完成后进入。

在调试模式下逐个运行来确认该问题。

Thread 是否运行不好?

这是我的代码。

#include
#include

#include

#include "ti_drivers_config.h"


#define ADC_SAMPLE_COUNT (100)

#define THREADSTACKSIZE  (768)

/* ADC 转换结果变量*/
uint16_t adcValue0[ADC_SAMPLE_COUNT];
uint32_t adcValue0MicroVol[ADC_SAMPLE_COUNT];
uint16_t adcValue1[ADC_SAMPLE_COUNT];
uint32_t adcValue1MicroVol[ADC_SAMPLE_COUNT];

extern void senddata (char* adcname、int time、int adcresult);

void timerCallback (Timer_handle myHandle、int_fast16_t 状态);

int sec = 0;

void *线程 Fxn0 (void * arg0)

   ADC_Handle  ADC;
   ADC_Params  参数;
   int_fast16_t res;
   uint16_t    i;

   ADC_PARAMS_INIT (params);
   ADC = ADC_open (CONFIG_ADC_0、params);

   if (ADC == NULL){
       while (1);
   }

   对于(I = 0;I < ADC_SAMPLE_COUNT;I++){
       RES = ADC_convert (ADC、&adcValue0[i]);

       if (res == ADC_STATUS_SUCCESS){

           adcValue0MicroVOL[i]= adc_convertRawToMicroVolts (ADC、adcValue0[i]);
       }
       否则{
       }
   }

   ADC_Close (ADC);

   返回(空);

void *线程 Fxn1 (void * arg0)

   uint16_t    i;
   ADC_Handle  ADC;
   ADC_Params  参数;
   int_fast16_t res;

   ADC_PARAMS_INIT (params);
   ADC = ADC_open (CONFIG_ADC_1、params);

   if (ADC == NULL){
     // Display_printf (display、0、0、"Error initializing CONFIG_ADC_1\n");
       while (1);
   }

   对于(I = 0;I < ADC_SAMPLE_COUNT;I++){
       RES = ADC_convert (ADC、&adcValue1[i]);

       if (res == ADC_STATUS_SUCCESS){

           adcValue1Microvol[i]= adc_convertRawToMicroVolts (adc、adcValue1[i]);
       }
       否则{
       }
   }

   ADC_Close (ADC);

   返回(空);

void * mainThread (void * arg0)

   pthread_t          thread0、thread1;
   pthread_attr_t     atttrs;
   struct sched_param primParam;
   int                retc;
   int                detachState;


   Timer_handle timer0;
   Timer_Params 参数;

   timer_init();

   Timer_Params_init (&params);
   params.period = 1000000;
   Params.periodUnits = Timer_Period_US;
   params.timerMode = Timer_Continuous_callback;
   params.timerCallback = timerCallback;

   timer0 = Timer_open (CONFIG_TIMER_0、params);

   if (timer0 == NULL){
       while (1){}
   }

   如果(Timer_start (timer0)= Timer_STATUS_ERROR){
       while (1){}
   }


   adc_init();

   pthread_attr_init (atttrs);

  detachState = pthread_create_detached;
  pthread_attr_setdetachstate (&atttrs、detachState);
  pthread_attr_setstacksize (&attrs、THREADSTACKSIZE);
  priParam.sched_priority = 1;
  pthread_attr_setschedparam (&attrs、&priParam);

  pthread_create (&thread0、&attrs、threadFxn0、(void*) 0);
  pthread_create (&thread1、&attrs、threadFxn1、(void*) 0);

   返回(空);

空 timerCallback (Timer_handle myHandle、int_fast16_t 状态)

   sec++;
   senddata ("ADC0"、秒、1000);

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

    您好!

    发布代码时、请使用语法 Highlighter。

     [引用用户="YOONJUNG Choi"]

    我尝试不是连续而是非连续使用 ADC 引脚。

    因此、我编写了参考示例代码的 ADC 信号通道的代码。

    ADC0和 ADC1线程被创建并且每个线程接收数据100次。

    我猜是 ADC0、ADC1将使用交替函数运行、但 ADC0将运行100次、ADC1将运行100次。

    此外、定时器也被置位、但是定时器在功能完成后进入。

    在调试模式下逐个运行来确认该问题。

    Thread 是否运行不好?

    [/报价]

    我不是很确定你要问什么。 您指的是什么主题? 如果我理解正确、ADC 线程工作正常、但您的计时器线程不工作?

    此致、

    James