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:
- 53:83a90a47c1fd
- Parent:
- 52:5a40cc58c4c2
- Child:
- 54:1697dc574b96
--- a/main.cpp Sat Jan 31 20:56:04 2015 +0000 +++ b/main.cpp Tue Feb 09 15:11:08 2016 +0000 @@ -1,27 +1,18 @@ #include "mbed.h" // Sampling -#include "Sample/adc.h" -#include "Sample/pdb.h" -#include "Sample/quad.h" - -#include "AngleEncoder.h" +#include "DMA_sampling/adc.h" // for debug purposes Serial pc(USBTX, USBRX); DigitalOut led_red(LED_RED); DigitalOut led_green(LED_GREEN); DigitalOut led_blue(LED_BLUE); -DigitalOut quadA(PTC17); -DigitalOut quadB(PTC16); - -AngleEncoder angle_encoder(PTD2, PTD3, PTD1, PTD0, 8, 0, 1000000); // mosi, miso, sclk, cs, bit_width, mode, hz // defined in dma.cpp extern int len; extern uint16_t sample_array0[]; extern uint16_t sample_array1[]; -extern uint16_t angle_array[]; using namespace std; @@ -29,63 +20,22 @@ led_blue = 1; led_green = 1; led_red = 1; - quadA = 0; - quadB = 0; pc.baud(230400); pc.printf("Starting\r\n"); - quad_init(); // initialize FTM2 to quadrature decoder adc_init(); // always initialize adc before dma + + pc.printf("ADC Initialized\r\n"); + dma_init(); // initializes DMAs - pdb_init(); // initialize PDB0 as the timer for ADCs and DMA2 led_green = 1; pc.printf("\r\n\r\n\r\n"); while(1) { - // creates signals for the quad decoder to read for testing - quadA = !quadA; - for(int i = 0; i < 65535; i++) asm("nop"); - quadB = !quadB; - - if(pc.readable() > 0) { - char temp = pc.getc(); - - switch(temp) { - case 'G': - case 'g': - pc.printf("Quad Cnt: %i\r\n", quad_read()); - break; - case 'F': // clear the samples - case 'f': - for(int i = 0; i < len; i++) {sample_array0[i] = 0; sample_array1[i] = 0; angle_array[i] = 0;} - pc.printf("Arrays cleared\r\n"); - // then display the samples - case 'S': // display what's been sampled - case 's': - for(int i = 0; i < len; i++) pc.printf("%i: %f\t %f\t %i\r\n",i,sample_array0[i]*3.3/65535,sample_array1[i]*3.3/65535, angle_array[i]); - pc.printf("\r\n"); - break; - - - // Programmable Delay Block debug - case 'B': - case 'b': - pc.printf("Started PCB...samples being taken\r\n"); - pdb_start(); - break; - case 'K': - case 'k': - pc.printf("Stopped PCB\r\n"); - pdb_stop(); - break; - case 'V': - case 'v': - pc.printf("PDB: %i\r\n",PDB0_CNT); - break; - } - } + pc.printf("%f",sample_array0[1]); + wait_ms(500); } } \ No newline at end of file