Motoot thank you for your example code ... i tried to use it in my application using CY8C4024LQI-S402 but i am stuck on how i use the API to get just the ADC count only. There is some simple API for getting readings in mVolts. I believe I am supposed to use the ADC_StartConvert(uint8 chld), but I am not sure, how to make sure the ADC has completed it measurement using the ADC_IsBusy(void) API. Can i get some help on how to do this properly using this single slope 10-bit ADC for this PSoC 4000S.
int16_t adc_counts ;
float value ;
///??? adc_counts = ?????
value = (float)adc_counts / (float)ADC_MAX ;
return( value ) ;
Below it the available API, I am confused as to how to actually get the count and not the voltage. I was successful in getting the ReadResult_mVolts to function and give me the correct voltage, but i need Count.
• cystatus ADC_StartConvert(uint8 chId)
Initializes the hardware and initiates an analog-to-digital conversion on the selected input channel.
• uint8 ADC_IsBusy(void)
The function returns the status of the ADC's operation.
• uint16 ADC_ReadResult_mVolts(uint8 chId)
This is a blocking API. It initiates a conversion, waits for completion and returns the result.
• uint16 ADC_GetResult_mVolts(uint8 chId)
This API does not perform an ADC conversion and returns the last valid result for the specified channel.