.. include:: ../substitutions.rst .. include:: stdout.rst DAC === The phyCORE-RT1170 features a built-in Digital-to-Analog Converter (DAC) with a 12-bit resolution. This allows it to generate analog voltages ranging from 0 V up to the internal reference voltage. Setting a Value via Shell ------------------------- Before the DAC can be used, the driver must be initialized. The RT1170 provides only a single DAC channel with a fixed 12-bit resolution. To initialize the channel, use the following command: .. code-block:: console :substitutions: |target-prompt| dac setup dac 0 12 To produce a specific output voltage, it's important to understand how the DAC translates digital values to analog voltages. The DAC operates with an internal reference voltage of 1.8 V. With 12-bit resolution, there are 4096 discrete output steps, meaning the digital value must fall within the range 0 to 4095. You can compute the required DAC value for a desired output voltage using the following formula: .. math:: \text{value} = 4095 \times \left( \frac{\text{voltage}}{1.8\,\text{V}} \right) Once you've calculated the appropriate value, write it to the DAC using: .. code-block:: console :substitutions: |target-prompt| dac write_value dac 0 Saw Tooth Example ----------------- .. jinja:: :file: templates/dac-sawtooth.jinja Source Code ~~~~~~~~~~~ .. literalinclude :: source-code/dac_sawtooth.c :language: c For more information see the |http-link-intf-dac-sawtooth| file.