Impedance Fast Circuitry Software

Dependencies:   mbed-dsp mbed

Fork of DSP_200kHz by Mazzeo Research Group

Committer:
bmazzeo
Date:
Fri Feb 19 19:01:30 2016 +0000
Revision:
58:4bee89daccff
Parent:
57:7b8c49e1c1f6
Child:
61:a56cca07d4a6
Definitely working at 100 kHz sampling - however, because of the DMA, there are some artifacts at the time of the sampling because the DMA is not instantaneous.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:bb128f0e952f 1 #include "mbed.h"
timmey9 22:523e316cbe70 2
timmey9 52:5a40cc58c4c2 3 // Sampling
bmazzeo 53:83a90a47c1fd 4 #include "DMA_sampling/adc.h"
bmazzeo 54:1697dc574b96 5 #include "DMA_sampling/dac.h"
bmazzeo 55:2526b3317bc8 6 #include "DMA_sampling/pdb.h"
timmey9 22:523e316cbe70 7
timmey9 22:523e316cbe70 8 // for debug purposes
timmey9 18:b17ddeeb1c09 9 Serial pc(USBTX, USBRX);
timmey9 18:b17ddeeb1c09 10 DigitalOut led_red(LED_RED);
timmey9 18:b17ddeeb1c09 11 DigitalOut led_green(LED_GREEN);
timmey9 18:b17ddeeb1c09 12 DigitalOut led_blue(LED_BLUE);
bmazzeo 58:4bee89daccff 13 DigitalOut status_0(D0);
bmazzeo 58:4bee89daccff 14 DigitalOut status_1(D1);
timmey9 51:43143a3fc2d7 15
timmey9 52:5a40cc58c4c2 16 // defined in dma.cpp
timmey9 45:d591d138cdeb 17 extern int len;
timmey9 45:d591d138cdeb 18 extern uint16_t sample_array0[];
timmey9 45:d591d138cdeb 19 extern uint16_t sample_array1[];
timmey9 41:3e0623d81b9a 20
bmazzeo 54:1697dc574b96 21 extern uint16_t static_input_array0[];
bmazzeo 54:1697dc574b96 22 extern uint16_t static_input_array1[];
bmazzeo 54:1697dc574b96 23
bmazzeo 55:2526b3317bc8 24 extern uint16_t static_output_array0[];
bmazzeo 56:7e08cbc3a4f1 25 extern uint16_t output_array0[];
bmazzeo 55:2526b3317bc8 26
bmazzeo 57:7b8c49e1c1f6 27 extern uint16_t sampling_status;
bmazzeo 57:7b8c49e1c1f6 28
timmey9 22:523e316cbe70 29 using namespace std;
timmey9 17:2f978f823020 30
emilmont 7:65188f4a8c25 31 int main() {
timmey9 22:523e316cbe70 32 led_blue = 1;
timmey9 35:df40c4566826 33 led_green = 1;
timmey9 18:b17ddeeb1c09 34 led_red = 1;
timmey9 34:44cc9b76a507 35
timmey9 18:b17ddeeb1c09 36 pc.baud(230400);
timmey9 34:44cc9b76a507 37 pc.printf("Starting\r\n");
timmey9 27:8c2b30c855d1 38
bmazzeo 55:2526b3317bc8 39 pdb_init(); // Initalize PDB
bmazzeo 55:2526b3317bc8 40
bmazzeo 54:1697dc574b96 41 dac_init(); // initializes DAC
bmazzeo 54:1697dc574b96 42
timmey9 45:d591d138cdeb 43 adc_init(); // always initialize adc before dma
bmazzeo 53:83a90a47c1fd 44
bmazzeo 53:83a90a47c1fd 45 pc.printf("ADC Initialized\r\n");
bmazzeo 53:83a90a47c1fd 46
timmey9 51:43143a3fc2d7 47 dma_init(); // initializes DMAs
bmazzeo 55:2526b3317bc8 48 dma_reset(); // This clears any DMA triggers that may have gotten things into a different state
timmey9 45:d591d138cdeb 49
bmazzeo 54:1697dc574b96 50
timmey9 46:a015ebf4663b 51 led_green = 1;
timmey9 38:ec3b16c130d7 52
timmey9 40:bd6d8c35e822 53 pc.printf("\r\n\r\n\r\n");
timmey9 37:8bdc71f3e874 54
bmazzeo 58:4bee89daccff 55 pdb_start();
timmey9 34:44cc9b76a507 56 while(1) {
bmazzeo 58:4bee89daccff 57 while(sampling_status == 0)
bmazzeo 58:4bee89daccff 58 {
bmazzeo 58:4bee89daccff 59 led_green = 1;
bmazzeo 58:4bee89daccff 60 status_0 = 1;
bmazzeo 58:4bee89daccff 61 }
bmazzeo 54:1697dc574b96 62
bmazzeo 58:4bee89daccff 63 sampling_status = 0;
bmazzeo 58:4bee89daccff 64 led_green = 0;
bmazzeo 58:4bee89daccff 65 status_0 = 0;
bmazzeo 58:4bee89daccff 66
bmazzeo 58:4bee89daccff 67 status_1 = 1;
bmazzeo 58:4bee89daccff 68 for(int i = 0; i < len; i++) {
bmazzeo 58:4bee89daccff 69 static_output_array0[i] = static_input_array0[i] >> 4;
bmazzeo 58:4bee89daccff 70 //pc.printf("%i\r\n", static_input_array0[i]);
bmazzeo 55:2526b3317bc8 71 }
bmazzeo 58:4bee89daccff 72 status_1 = 0;
bmazzeo 55:2526b3317bc8 73 }
bmazzeo 55:2526b3317bc8 74
bmazzeo 55:2526b3317bc8 75
bmazzeo 58:4bee89daccff 76
timmey9 42:52a92a8d2cc7 77 }