7.2.2.10 GPADC
Instructions on how to perform a software conversion with the GPADC:
- Enable software conversion mode – GPADC_SW_SELECT.SW_CONV_EN
- Select the channel to convert – GPADC_SW_SELECT.SW_CONV0_SEL
- For channel 0, set up the current source in the GPADC_CTRL1 register if needed.
- For minimum latency, the GPADC can be set to always on (instead of default enabled from conversion request) by GPADC_CTRL1.GPADC_FORCE.
- Unmask software conversion interrupt – INT3_MASK.GPADC_EOC_SW
- Start conversion – GPADC_SW_SELECT.SW_START_CONV0.
- An interrupt is generated at the end of the conversion INT3_STATUS.GPADC_EOC_SW.
- Read conversion result – GPADC_SW_CONV0_MSB and GPADC_SW_CONV0_LSB
- Expected result = dec(GPADC_SW_CONV0_MSB[3:0].GPADC_SW_CONV0_LSB[7:0])/ 4096 × 1.25 × scalar
Instructions on how to perform an auto conversion with the GPADC:
- Select the channel to convert – GPADC_AUTO_SELECT.AUTO_CONV0_SEL
- Configure auto conversion frequency – GPADC_AUTO_CTRL.COUNTER_CONV
- Set the threshold level for comparison – GPADC_THRESH_CONV0_MSB.THRESH_CONV0_MSB, GPADC_THRESH_CONV0_LSB.THRESH_CONV0_LSB
- Level = expected voltage threshold / (1.25 × scalar) × 4096 (in hexadecimal)
- Set if the interrupt is triggered when conversion is above or below threshold – GPADC_THRESH_CONV0_MSB.THRESH_CONV0_POL
- Triggering the threshold level can also be programmed to generate shutdown – GPADC_AUTO_CTRL.SHUTDOWN_CONV0
- Unmask AUTO_CONV_0 interrupt – INT3_MASK.GPADC_AUTO_0
- Enable AUTO CONV0 – GPADC_AUTO_CTRL.AUTO_CONV0_EN
- When selected channel crosses programmed threshold, interrupt is generated – INT3_STATUS.GPADC_AUTO_0
- Conversion results are available – GPADC_AUTO_CONV0_MSB, GPADC_AUTO_CONV0_LSB
- If shutdown was enabled, chip switches off after SWOFF_DLY, unless interrupt is cleared
The example above is for CONV0; a similar procedure applies to CONV1.