The fixedfrequencydac object represents a 12-bit fixed-frequency digital-to-analog converter (DAC). It is only available on the imp001, imp002, imp003 and (from impOS™ 42) the imp006. It is not available on the imp005. While the imp004m also lacks a true fixed-frequency DAC, it is nevertheless possible to use this API for audio output provided your device is fitted with a simple filter circuit. For more details, please see the fixedfrequencydac.configure() documentation.
Note The fixedfrequencydac is not currently available to versions of impOS running on the impC001.
fixedfrequencydac is instantiated automatically by impOS at start-up as a property of the hardware object. Though the object is instantiated for you, you must configure it before use. The DAC can be configured to output on either pin 1 or 5 (imp001, imp002); pin A or C (imp003); or pin XC or XD (imp006) at a specified sample rate.
The imp004m’s DAC emulation is output on pins K and D, which are specified using the object hardware.pwmpairKD. Optionally, the source buffers can be A-law compressed, in which case the data is decompressed on the fly.
When each buffer has been consumed, a nominated function is called automatically. This data-consumed callback is registered using fixedfrequencydac.configure() and must be implemented if you plan to use an imp DAC.
Consumption of the data by the DAC proceeds ‘in the background’, under interrupt. To stop the fixed-frequency DAC after a certain time, set a timer using imp.wakeup(). This is demonstrated in the examples included with the fixedfrequencydac methods.
The fixedfrequencydac object has the following member methods: