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:
- 40:bd6d8c35e822
- Parent:
- 39:82dc3daecf32
- Child:
- 41:3e0623d81b9a
--- a/main.cpp Thu Jan 29 16:18:54 2015 +0000 +++ b/main.cpp Fri Jan 30 06:16:39 2015 +0000 @@ -16,7 +16,7 @@ // Analog sampling #define MAX_FADC 6000000 #define SAMPLING_RATE 10 // In microseconds, so 10 us will be a sampling rate of 100 kHz -#define TOTAL_SAMPLES 3 // originally 30000 for 0.3 ms of sampling. +#define TOTAL_SAMPLES 100 // originally 30000 for 0.3 ms of sampling. // for debug purposes Serial pc(USBTX, USBRX); @@ -31,8 +31,7 @@ // Analog sampling Ticker Sampler; - -uint16_t sample_array1[TOTAL_SAMPLES] = {0xa,0xb,0xc}; +uint16_t sample_array1[TOTAL_SAMPLES]; uint16_t sample_array2[TOTAL_SAMPLES]; uint16_t angle_array[TOTAL_SAMPLES]; float currA0 = 0; @@ -46,7 +45,7 @@ int rotary_count = 0; uint32_t last_AMT20_AB_read = 0; -void PIT0_IRQHandler(void); +void ADC0_IRQHandler(void); using namespace std; @@ -58,18 +57,11 @@ pc.baud(230400); pc.printf("Starting\r\n"); - //for(int i = 0; i < 3; i++) pc.printf("Sample[%i]: %x\r\n", i, sample_array1[i]); - - dma_init(sample_array1, sample_array2, angle_array, TOTAL_SAMPLES, pc); + dma_init(TOTAL_SAMPLES); analog_initialization(A0,pc); - //pdb_init(pc); - //pdb_start(); + pc.printf("\r\n\r\n\r\n"); - //Sampler.attach_us(&timed_sampling, SAMPLING_RATE); - - pc.printf("\r\n\r\n\r\n"); - //while(1) {pc.printf("CNT: %04x\r\n",PDB0->CNT);} while(1) { rotary_count++; if(pc.readable() > 0) { @@ -77,7 +69,7 @@ switch(temp) { case 's': - for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("%i: %f\t",i,sample_array1[i]*3.3/65535); + for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("%i: %f\r\n",i,sample_array1[i]*3.3/65535); pc.printf("\r\n"); break; @@ -87,18 +79,23 @@ case 'd': for(int i = 0; i < 3; i++) pc.printf("Sample[%i]: %x\r\n", i, sample_array1[i]); break; + case 'a': + start_adc(); + wait(1); + stop_adc(); + break; } } - for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("A%i: %f ",i,sample_array1[i]*3.3/65535); + //for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("A%i: %f ",i,sample_array1[i]*3.3/65535); - pc.printf("ADC0_RA: %08x\r\n",ADC0_RA); - pc.printf("ADC0_RB: %08x\r\n",ADC0_RB); + //pc.printf("ADC0_RA: %08x\r\n",ADC0_RA); + //pc.printf("ADC0_RB: %08x\r\n",ADC0_RB); //for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("B%i: %f ",i,sample_array2[i]*3.3/65535); //for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("C%i: %i ",i,angle_array[i]); - pc.printf("\r"); + //pc.printf("DMA_DADDR: %08x \r", *dma_daddr); //pc.printf("A1: %f\tA2: %f\r\n", currA0, currA2); - wait(1); + //wait(1); } } @@ -127,4 +124,5 @@ last_AMT20_AB_read = AMT20_AB; } -} \ No newline at end of file +} +