Hi
I was working on the "TWR-K70120M" in which I was trying to understand the "LWADC" example which I found on the following path "C:\Freescale\Freescale_MQX_4_1\mqx\examples\lwadc\build\uv4\lwadc_twrk70f120m".
So, while debugging I observed one thing that there is one function which is printing all the attributes on the uart
print_all_lwadc_attributes(&potentiometer); (image is attached below)
So, now I really want to know how we can decide exact values for the ADC attributes??. Also, I already have gone through the readme.pdf file but unfortunately, it wasn't mentioned there. Can anyone please help me to understand this?.
Regards
Omkar Dixit
Solved! Go to Solution.
From the source code, the other attributes values are initialized in function _lwadc_init () , mqx/source/io/lwadc/lwadc_vadc.c line 47
Hi omkardixit:
We get the real attribute value through API _lwad_read_raw()
mqx/source/io/lwadc/lwadc_vadc.c
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name : _lwadc_read_raw
* Returned Value : TRUE for success, FALSE for failure
* Comments :
* This function Read the current value of the ADC input and return
* the result without applying any scaling.
*
*END*----------------------------------------------------------------------*/
bool _lwadc_read_raw(LWADC_STRUCT_PTR lwadc_ptr, LWADC_VALUE_PTR outSample)
{
ADC_MemMapPtr adc_ptr;
LWADC_VALUE sample;
if (NULL == lwadc_ptr){
return FALSE;
}
if (lwadc_ptr->context_ptr == NULL) {
return FALSE;
}
adc_ptr = lwadc_ptr->context_ptr->adc_ptr;
if ((adc_ptr->GC & ADC_GC_ADCO_MASK) == 0) {
/* ADC is not in continuous mode. */
adc_ptr->GC |= ADC_GC_ADCO_MASK;
}
sample = adc_ptr->R[0];
*outSample = sample & ADC_CDR_CDATA_MASK;
return TRUE;
}
Regards
Daniel
Hi Daniel,
Thanks for your reply. Yes, I have tried the API you mentioned. If you see the image which I have uploaded, consists of the ADC attributes eg. LWADC_FORMAT, LWADC_DIVIDER, and more.
So, my dought is except the LWADC_RESOLUTION & LWADC_FREQUNCY attributes how can we decide the values of the other attributes. If in the case of my next project again I need to work with ADC so how can I decide the values of the attributes?.
Regards
Omkar Dixit
From the source code, the other attributes values are initialized in function _lwadc_init () , mqx/source/io/lwadc/lwadc_vadc.c line 47