diff --git a/sampling.c b/sampling.c index 118936e..f661b22 100644 --- a/sampling.c +++ b/sampling.c @@ -2,8 +2,15 @@ #include #include "inc/tm4c1294ncpdt.h" #include "driverlib/adc.h" +#include "driverlib/pin_map.h" +#include "driverlib/gpio.h" +#include "driverlib/sysctl.h" +#include "driverlib/interrupt.h" #include "sysctl_pll.h" #include "inc/hw_types.h" +#include "inc/hw_memmap.h" +#include +#include "buttons.h" #define ADC_BUFFER_SIZE 2048 // size must be a power of 2 @@ -23,9 +30,9 @@ void ADC_ISR(void) gADCErrors++; // count errors ADC1_OSTAT_R = ADC_OSTAT_OV0; // clear overflow condition } - gADCBufferIndex = ADC_BUFFER_WRAP(gADCBufferIndex + 1) + gADCBufferIndex = ADC_BUFFER_WRAP(gADCBufferIndex + 1); // read sample from the ADC1 sequence 0 FIFO - gADCBuffer[gADCBufferIndex] = ADC1_SSFIFO0_R & 0xFFF; + gADCBuffer[gADCBufferIndex] = (ADC1_SSFIFO0_R & ADC_SSFIFO0_DATA_M); } @@ -50,13 +57,12 @@ void start_sampler() { 0); // specify the "Always" trigger // in the 0th step, sample channel 3 (AIN3) // enable interrupt, and make it the end of sequence - ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH3)); + ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH3); // enable the sequence. it is now sampling ADCSequenceEnable(ADC0_BASE, 0); // enable sequence 0 interrupt in the ADC1 peripheral - ADCIntEnable(INT_ADC1SS0); + ADCIntEnable(ADC1_BASE, INT_ADC1SS0); IntPrioritySet(INT_ADC1SS0, 0); // set ADC1 sequence 0 interrupt priority // enable ADC1 sequence 0 interrupt in int. controller IntEnable(INT_ADC1SS0); - -} \ No newline at end of file +}