2015-03-18 07:55 AM
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. #adc2015-03-18 08:17 AM
2015-03-18 08:23 AM
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.2015-03-19 01:07 AM
Hi Mike,
Why are you trying to read the driver states? under normal circumstances this should not be required. Giovanni2015-03-19 02:15 AM
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.2015-03-19 08:09 AM
Hi,
Unless you are using a circular buffer you don't need to stop conversions. The function adcConvert() returns after the conversion is finished, no need to synchronize. The function adcStartConvert() starts the conversion and gives you a callback on conversion finish (and it stops there unless you used a circular buffer). Giovanni2015-03-26 06:01 AM
That means I can (or need to) write separate callback for each ADC channel configured? And using each callback, I can collect ADC data when I initiate conversion for respective channel using adcStartConvert(). Is my understanding correct?
Thanks.Mike.2015-03-27 03:21 AM
2015-04-22 03:51 AM
Hello Erwan,
Referring to below mail, I have configured an ADC channel for SPC560D30L1. I am using linear buffer with maximum sequential set to 1. 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'');}2015-04-22 04:44 AM
Hello Mike ,
yes for a linear buffer you shouldre-start the conversion
after each ADC Conversion.Maybe you should switch to the circular mode no need to restart the conversionwith maximum sequential set to 1 , it should be the latest value.