|
Hi blueblood,
Here are my suggestions after testing your project:
1) First and foremost, please update to the latest version of PSoC Creator. The link is http://www.cypress.com/?id=2494&source=header . I updated the componentes in the project to the latest ones.
2) The variable used to store the ADC converted value "result" was declared as "int". Declaring it as an uint8 is better in this case as you are using it in single ended mode with the input varying from Vss to Vdd (0V - 5V). Using "int" is advisable when using ADC in differential mode where both negative and positive values are to be expected.
3) As is advised in the ADC Component datasheet, it is recommended to use the GetResult16( ) API when ADC is configured for 8 bits mode or higher and GetResult32( ) when ADC is configured for 16 bit mode or higher. When "result" is declared as "uint16" variable, there is no error due to rolling off of the ADC value when the input slightly exceeds 5.00V. The roll-over error persists when GetResult8( ) is used.
4) For the ADC to continuously measure the input voltage, the ADC conversion mode is set to "Continuous". The updating of LCD is done in an infinite loop { while(1) } after waiting for the conversion to end.
5) There are APIs which directly gives the counts in Volts, mVolts, and uVolts. The APIs are ADC_CountsTo_Volts( ), ADC_CountsTo_mVolts( ) and ADC_CountsTo_uVolts( ) respectively. You can use it to your advantage as it frees you from computing the Voltage explicitly.
6) When using these APIs, remember to set the right values for Vdda (as this is the reference). This can be done is .cydwr > System > Voltage Configuration. Set it to appropriate value as thje Vdda provided to the device.
|