06 Dec 2020 19:18:02 UTC
- Distribution: Device-Chip-AD9833
- Module version: 0.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (83 / 0 / 29)
- KwaliteeBus factor: 1
- 74.62% Coverage
- License: perl_5
- Perl: v5.26.0
- Activity24 month
- Download (12.81KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPEVANS Paul Evans
Device::Chip::AD9833- chip driver for AD9833
use Device::Chip::AD9833; use Future::AsyncAwait; my $chip = Device::Chip::AD9833->new; await $chip->mount( Device::Chip::Adapter::...->new ); await $chip->init; my $freq = 440; # in Hz await $chip->write_FREQ0( ( $freq << 28 ) / 25E6 ); # presuming 25MHz reference
This Device::Chip subclass provides specific communication to an Analog Devices AD9833 attached to a computer via an SPI adapter.
The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them.
The following methods documented in an
awaitexpression return Future instances.
Resets the chip to a working configuration, including setting the
B28bit appropriately for the way this module writes the frequency registers.
$config = await $chip->read_config;
HASHreference containing the current chip configuration. Note that since the chip does not support querying the configuration, this is just an in-memory copy maintained by the object instance, updated by calls to "change_config".
The hash will contain the following named fields, all booleans.
B28 HLB FSELECT PSELECT SLEEP1 SLEEP12 OPBITEN DIV2 MODE
In addition, a new value
wavewill be created combining the current settings of
DIV2to explain the waveform generated
wave => "sine" | "triangle" | "square" | "square/2"
await $chip->change_config( %changes );
Writes updates to the chip configuration. Takes named arguments of the same form as returned by "read_config", including the synthesized
await $chip->write_FREQ0( $freq ); await $chip->write_FREQ1( $freq );
FREQ1frequency control register.
$freqshould be a 28bit integer value.
await $chip->write_PHASE0( $phase ); await $chip->write_PHASE1( $phase );
PHASE1phase control register.
$phaseshould be a 12bit integer value.
Paul Evans <email@example.com>
Module Install Instructions
To install Device::Chip::AD9833, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Device::Chip::AD9833
For more information on module installation, please visit the detailed CPAN module installation guide.