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.
Fork of Impedance_Fast_Circuitry by
Diff: main.cpp
- Revision:
- 55:2526b3317bc8
- Parent:
- 54:1697dc574b96
- Child:
- 56:7e08cbc3a4f1
--- a/main.cpp Tue Feb 16 18:33:44 2016 +0000 +++ b/main.cpp Wed Feb 17 20:26:26 2016 +0000 @@ -3,6 +3,7 @@ // Sampling #include "DMA_sampling/adc.h" #include "DMA_sampling/dac.h" +#include "DMA_sampling/pdb.h" // for debug purposes Serial pc(USBTX, USBRX); @@ -18,6 +19,8 @@ extern uint16_t static_input_array0[]; extern uint16_t static_input_array1[]; +extern uint16_t static_output_array0[]; + using namespace std; int main() { @@ -28,6 +31,8 @@ pc.baud(230400); pc.printf("Starting\r\n"); + pdb_init(); // Initalize PDB + dac_init(); // initializes DAC adc_init(); // always initialize adc before dma @@ -35,6 +40,7 @@ pc.printf("ADC Initialized\r\n"); dma_init(); // initializes DMAs + dma_reset(); // This clears any DMA triggers that may have gotten things into a different state led_green = 1; @@ -56,7 +62,7 @@ //for(int i = 0; i < len; i++) pc.printf("B%i: %d\t %d\r\n",i,static_input_array0[i],static_input_array1[i]); //wait_ms(1000); - int store_var = DMA_TCD2_CSR; +/* int store_var = DMA_TCD2_CSR; if (store_var == 0x220) { DAC0_DAT0H = 0x0F; @@ -70,12 +76,70 @@ } //int store_var = DMA_TCD0_CSR; - pc.printf("DMA0: %x\r\n", DMA_TCD0_CSR); - pc.printf("DMA1: %x\r\n", DMA_TCD1_CSR); - pc.printf("DMA2: %x\r\n", DMA_TCD2_CSR); - pc.printf("DMA3: %x\r\n", DMA_TCD3_CSR); + //pc.printf("DMA0: %x\r\n", DMA_TCD0_CSR); + //pc.printf("DMA1: %x\r\n", DMA_TCD1_CSR); + //pc.printf("DMA2: %x\r\n", DMA_TCD2_CSR); + //pc.printf("DMA3: %x\r\n", DMA_TCD3_CSR); + + //for(int i = 0; i < len; i++) pc.printf("B%i: %d\t %d\r\n",i,static_input_array0[i],static_input_array1[i]); + for (int i = 0: i < len; i++) + { + static_output_array[i] = static_input_array0[i] >> 4; + } //wait_us(100); + */ + if(pc.readable() > 0) { + char temp = pc.getc(); + + switch(temp) { + case 'F': // clear the samples + case 'f': + for(int i = 0; i < len; i++) {sample_array0[i] = 0; sample_array1[i] = 0;} + pc.printf("Arrays cleared\r\n"); + // then display the samples + break; + case 'S': // display what's been sampled + case 's': + for(int i = 0; i < len; i++) pc.printf("%i: %f\t %f\t %f\t %f\r\n",i,sample_array0[i]*3.3/65535,sample_array1[i]*3.3/65535,static_input_array0[i]*3.3/65535,static_input_array1[i]*3.3/65535); + pc.printf("\r\n"); + break; + + case 'D': // DMA debug + case 'd': + pc.printf("DMA Status:\r\n"); + pc.printf("DMA_TCD0_SOFF: %x\r\n", DMA_TCD0_SOFF); + pc.printf("DMA_TCD1_SOFF: %x\r\n", DMA_TCD1_SOFF); + pc.printf("DMA_TCD0_CITER_ELINKNO: %x\r\n", DMA_TCD0_CITER_ELINKNO); + pc.printf("DMA_TCD0_BITER_ELINKNO: %x\r\n", DMA_TCD0_BITER_ELINKNO); + pc.printf("DMA_TCD1_CITER_ELINKNO: %x\r\n", DMA_TCD1_CITER_ELINKNO); + pc.printf("DMA_TCD1_BITER_ELINKNO: %x\r\n", DMA_TCD1_BITER_ELINKNO); + pc.printf("DMA_TCD2_CITER_ELINKNO: %x\r\n", DMA_TCD2_CITER_ELINKNO); + pc.printf("DMA_TCD2_BITER_ELINKNO: %x\r\n", DMA_TCD2_BITER_ELINKNO); + pc.printf("DMA_TCD3_CITER_ELINKNO: %x\r\n", DMA_TCD3_CITER_ELINKNO); + pc.printf("DMA_TCD3_BITER_ELINKNO: %x\r\n", DMA_TCD3_BITER_ELINKNO); + + break; + + // Programmable Delay Block debug + case 'B': + case 'b': + pc.printf("Started PDB...samples being taken\r\n"); + pdb_start(); + break; + case 'K': + case 'k': + pc.printf("Stopped PDB\r\n"); + pdb_stop(); + break; + case 'V': + case 'v': + pc.printf("PDB: %i\r\n",PDB0_CNT); + break; + } + } + + } } \ No newline at end of file