Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:1d2510530829
- Parent:
- 1:a22687a74345
--- a/main.cpp Fri Jan 31 15:14:42 2020 +0000
+++ b/main.cpp Fri Jan 31 15:55:14 2020 +0000
@@ -21,6 +21,8 @@
void WriteRegister(short dat) {
fsyncpin = 0; // Set FSYNC low before writing to AD9833 registers
+ // printf("writing register with %i.\r\n");
+
wait_us(10); // Give AD9833 time to get ready to receive data.
spi.write(dat >> 8); // Each AD9833 register is 32 bits wide and each 16
@@ -35,7 +37,9 @@
void AD9833setFrequency(long frequency, int Waveform) {
- long FreqWord = (frequency * pow(2, 28.0)) / refFreq;
+ long FreqWord = (frequency * 0x1000000) / refFreq;
+
+ printf("freq word: %ld\r\n", FreqWord);
int MSB = (int)((FreqWord & 0xFFFC000) >> 14); //Only lower 14 bits are used for data
int LSB = (int)(FreqWord & 0x3FFF);
@@ -52,8 +56,9 @@
}
void setup() {
- spi.format(16, 2); // set to 16 bit data and mode 2
- spi.frequency(freq); // set initial fequency
+ fssyncpin = 1;
+ spi.format(8, 2); // set to 16 bit data and mode 2
+ spi.frequency(1000000); // set initial fequency
AD9833reset(); // Reset AD9833 module after power-up.