10 Analog I/O
The analog tests available in the library are performed on internal signals only. Two different test functions are available in the library:
- ADC reading of a level generated by the DAC routed internally on the device. The reference voltage for each peripheral is generated from the bandgap voltage.
- Similar to above, but with VDD as ADC reference voltage.
All tests are not required to run in order to be class B compliant.
Test one and two are very similar, but if the device is running with a stable VDD, test two will give somewhat more coverage as this has a somewhat larger chance of finding deviations in the bandgap voltage. Since test two requires a higher degree of accuracy on VDD, it should not be used for battery applications or applications where VDD is likely to be very noisy during testing. If VDD is noisy, or there is much variation from one circuit to another, it may also be necessary to have a higher acceptable range of conversion values from the ADC.
Test one is somewhat simpler than test two and three. As both the DAC and the ADC get the reference from the bandgap voltage, it cannot detect if the bandgap is wrong. It can detect if the two separate reference generators sourced by the bandgap are different or wrong.
All tests will test the DAC, ADC, and reference voltage system, however, if the test fails it cannot tell which of these have failed. If e.g., the test is used to validate correct ADC behavior in case this is the only component being used an error present in the DAC or the reference generator to the DAC can cause the tests to fail. This could then lead to the application not being executed even when this would be safe.
The example code executes test 1 and 2 in a continuous loop, with two LEDs respectfully indicating test status. If a test fails, it will turn the corresponding LED OFF.
- The ADC clock can be changed to be faster
- The acceptable conversion range can be adjusted so that the test fails
- The reference voltage to either the DAC or the ADC can be changed