ST意法半导体
直播中

丛聪

7年用户 286经验值
私信 关注
[问答]

怎么使用不同的ADC驱动程序状态来实现状态机

你好,

我正在尝试使用Discovery驱动程序将ADC驱动程序(ADCD2)用于SPC560D30L3设备(我已将SPC560D40替换为SPC560D30 MCU)。我正在尝试使用不同的ADC驱动程序状态来实现状态机。如果我的理解是正确的,我将进入以下状态,

开关(ADCD2.state)
{
案例ADC_UNINIT:
打破;
案例ADC_STOP:

打破;

案例ADC_READY:

打破;

案例ADC_ACtiVE:

打破;

案例ADC_COMPLETE:

打破;

案例ADC_ERROR:

打破;

}

如果上述方法是正确的,则“ADCD2.state”语句本身不起作用!任何人都可以澄清这个问题吗?还需要哪些其他设置?

在此先感谢您的帮助。
麦克风。
#adc

以上来自于谷歌翻译


以下为原文





Hello,

I am trying to use the ADC driver (ADCD2) for SPC560D30L3 device using Discovery kit (I have replaced SPC560D40 with SPC560D30 MCU). I am trying to implement a state machine using different states of ADC driver. If my understanding is correct, I shall access the states as below,

switch (ADCD2.state)
{
case ADC_UNINIT:
break;
case ADC_STOP:

break;

case ADC_READY:

break;

case ADC_ACTIVE:

break;

case ADC_COMPLETE:

break;

case ADC_ERROR:

break;

}

If above way is correct the statement 'ADCD2.state' itself is not working! Can anybody clarify the issue? What other settings are required?

Thanks in advance for your help.
Mike.  
#adc

回帖(7)

丛聪

2019-4-28 10:40:13
你好,Erwan,
 
感谢您的回复。你能解释一下如何使用补丁模式吗?我需要参考哪些文件来理解修补?
谢谢。
麦克风。

以上来自于谷歌翻译


以下为原文





Hello Erwan,

Thanks for reply. Can you please explain how to use the patch mode? Whcih document I need to refer for understanding the patching?
Thanks.
Mike.
举报

丛聪

2019-4-28 11:09:36
我有3-4个ADC通道配置用于测量。根据应用程序要求,我将启动所有或单个通道测量(即ADC_Start_Conversion)。主要功能将遵循ADC状态,以了解何时停止ADC并进行测量(即ADC_Stop_Conversion)。这是我的要求。能否详细说明如何利用不同的驱动程序状态/标志来实现这一点?
 
 
提前致谢。
麦克风。

以上来自于谷歌翻译


以下为原文





I have 3-4 ADC channels configured for measurements. Based on the app requirement, I will initiate all or individual channel measurements (i.e. ADC_Start_Conversion). The main function will follow the ADC states to know when to stop the ADC and do the measurements (ie.e ADC_Stop_Conversion). This is my requirement. Can you please elaborate how I can make use of different driver states/flags to implement this?


Thanks in advance.
Mike.
举报

刘鑫

2019-4-28 11:34:41
你好迈克,
 
您可以通过配置器为每个ADC通道编写(非强制)一些单独的回调
(Cf截图)。
 
如果您的ADC配置处于模式,则无需重新启动转换。
它会自动重启。
 
 最好的祝福
 
 二万

以上来自于谷歌翻译


以下为原文







Hello Mike ,

You can write (not mandatory) some separate callbacks for each ADC Channel by the configurator
(Cf screenshot).

If your ADC configuration is in  mode, no need to restart the conversion.
it is automatically restarted.

             Best Regards

                            Erwan
举报

丛聪

2019-4-28 11:50:24
你好,Erwan,
 
参考下面的邮件,我为SPC560D30L1配置了一个ADC通道。我正在使用设置为。我已将回调配置为读取ADC计数并将其转换为电压值。在这里,我观察到需要启动ADC转换(ADC_Start_Conversion)以读取新的输入值。我是在按键上做的。如何配置ADC以进行连续读取并在输入更改时获取更新的计数值?
 
请注意,我需要相互独立的3-4个ADC通道,我需要类似的功能。怎么实现这个?
 
在此先感谢您的帮助。
麦克风。
 
请在下面找回回调,
/ *
 * ADC流回调,名称在ADC图形中定义
 *配置。
 * /
size_t nx = 0,ny = 0;
void ADC_conversion_callback(ADCDriver * adcp,adcsample_t * buffer,size_t n)
{
 (空隙)ADCP;
 if(samples == buffer)
 {
 nx + = n;
 }
 其他
 {
 ny + = n;
 }
 g_adc_val = samples [0];
 g_adc_vol =((5.0 / 4096)* g_adc_val);
}
 
 
/ *
 * ADC错误回调,名称在ADC图形中定义
 *配置。
 * /
uint32_t errore = 30;
void ADC_error_callback(ADCDriver * adcp,adcerror_t err)
{
 (空隙)ADCP;
 错误=错误;
 
 osalSysHalt(''ADC失败'');
}

以上来自于谷歌翻译


以下为原文




Hello Erwan,

Referring to below mail, I have configured an ADC channel for SPC560D30L1. I am using  with  set to . I have configured the callbacks to read the ADC count and to convert it to voltage value. Here, I have observed that ADC conversion is required to be initiated (ADC_Start_Conversion) in order to read the new input value. I am doing this on a key press. How can I configure the ADC for continuous read and get the updated count value when input changes?  

Please note that I have 3-4 more ADC channels independent of each other where I required similar functionality. How to implement this?

Thanks in advance for your help.
Mike.

Please find below the callbacks,
/*
* ADC streaming callback, the name is defined in the ADC graphic
* configuration.
*/
size_t nx = 0, ny = 0;
void ADC_conversion_callback (ADCDriver *adcp, adcsample_t *buffer, size_t n)
{
  (void)adcp;
  if (samples == buffer)
  {
    nx += n;
  }
  else
  {
    ny += n;
  }
  g_adc_val = samples[0];
  g_adc_vol = ((5.0/4096)*g_adc_val);
}


/*
* ADC error callback, the name is defined in the ADC graphic
* configuration.
*/
uint32_t errore = 30;
void ADC_error_callback (ADCDriver *adcp, adcerror_t err)
{
  (void)adcp;
  errore = err;

  osalSysHalt(''ADC failure'');
}
举报

更多回帖

发帖
×
20
完善资料,
赚取积分