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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:c2b09e28978a
- Parent:
- 2:eb558d650b17
- Child:
- 4:42262a293f60
--- a/main.cpp Tue Mar 24 22:11:00 2015 +0000
+++ b/main.cpp Mon Apr 06 18:06:52 2015 +0000
@@ -8,22 +8,19 @@
SPI SPI_AFE_ADC_AND_DDS(p5, p6, p7); //SPI0: MOSI, MISO, SCLK
DigitalOut ADC_nCS(p8); //ADC_!CS
-DigitalOut DDS_nCS(p15); //DDS_!CS
-
-SPI SPI_CUR_ADC(p11, p12, p13); //SPI1 - see page 601 of 947
-DigitalOut CUR_nCS(p14); //DDS_!CS
// These pins control the Phase register and the Frequency register, IF THE DDS IS CONFIGURED TO BE CONTROLLED BY THE PINS,
//BY DEFAULT, AND HOW I HAVE IT CONFIGURED IS TO NOT USE THESE PINS, REPEAT, it does NOT USE THE PINS, instead uses the SPI bus.
// By toggling them after config, you can create PSK, FSK, BPSK...
+DigitalOut CURRENT(p14); //if=1, output of CSM to input selector / switch 2
+DigitalOut DDS_nCS(p15); //nCS line used for SPI on
DigitalOut DDS_PSEL(p16);
DigitalOut DDS_FSEL(p17);
-DigitalOut SQUARE(p18); //currently does nothing, =1 closes switch to SQUARE path that is not populated
+DigitalOut SQUARE(p18); //if=1 closes switch to SQUARE path that is not populated
DigitalOut DDS(p19); //if=1, DDS output connected to TX_PORT
DigitalOut AFE(p20); //if=1, Electrode routed to Amplification Path
-
#define SSP_SR_TFE (1<<0)
#define SSP_SR_TNF (1<<1)
#define SSP_SR_RFE (1<<2)
@@ -168,7 +165,6 @@
//nCS lines
DDS_nCS = 1;
- CUR_nCS = 1;
ADC_nCS = 1;
//init spi
@@ -179,12 +175,16 @@
//init DDS
begin();
//output calculation
- //fOut = fMCLK / 2^28 * FREQREG = 16e6 / 2^28 * FREQREG
- //FREQREG = fOut * 2^28 / 16e6 = fOut * 16.777216
- setFrequencyWord(0, 16777216); //1MHz: bin 0
- setFrequencyWord(1, 33554432); //2MHz: bin 1
+ //fOut = fMCLK / 2^28 * FREQREG = 50e6 / 2^28 * FREQREG
+ //FREQREG = fOut * 2^28 / 50e6 = fOut * 5.36870912
+ //1 MHz: 5368709, 2 MHz: 10737418, 3 MHz: 16106127, 4 MHz: 21474836, 8 MHz: 42949673 MHz, 20 MHz: 107374182, Max: 0x3FFF
+ setFrequencyWord(0, 42949673);
+ setFrequencyWord(1, 0x3FFF);
+ selectFrequency(0);
+ //setOutputMode(OUTPUT_MODE_SINE);
setSignOutput(SIGN_OUTPUT_MSB);
+ //setSignOutput(SIGN_OUTPUT_COMPARATOR); //max output freq appx 6.357 MHz?
//open the DDS output
SQUARE = 1;
@@ -200,6 +200,7 @@
int32_t freq = 0;
uint8_t freqRegister = 0;
+
__disable_irq();
while(1) {
for (bytecount=0; bytecount<data_len; bytecount++){