Other Parts Discussed in Thread: EK-TM4C123GXL
//*****************************************************************************
//
// project0.c - Example to demonstrate minimal TivaWare setup
//
// Copyright (c) 2012-2017 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.4.178 of the EK-TM4C123GXL Firmware Package.
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_adc.h"
#include "inc/hw_types.h"
#include "inc/hw_udma.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/adc.h"
#include "driverlib/udma.h"
#include "driverlib/timer.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/systick.h"
#include "utils/uartstdio.h"
//*****************************************************************************
//
// Define pin to LED color mapping.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Project Zero (project0)</h1>
//!
//! This example demonstrates the use of TivaWare to setup the clocks and
//! toggle GPIO pins to make the LED's blink. This is a good place to start
//! understanding your launchpad and the tools that can be used to program it.
//
//*****************************************************************************
#define RED_LED GPIO_PIN_1
#define BLUE_LED GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
//
// Main 'C' Language entry point. Toggle an LED using TivaWare.
//
//*****************************************************************************
uint32_t adcbuffer[100];
uint32_t adcdata1[100];
uint32_t adcdata2[100];
uint32_t i,timebase,triglvl,xpos;
void main(){
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //20 MHz clock
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH7 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH6 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCSequenceEnable(ADC1_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
while(1)
{
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
ADCIntClear(ADC1_BASE, 3);
ADCProcessorTrigger(ADC1_BASE, 3); // Trigger the ADC conversion.
while(!ADCIntStatus(ADC1_BASE, 3, false)){} // Wait for conversion to be completed.
ADCIntClear(ADC1_BASE, 3); // Clear the ADC interrupt flag.
ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer); // Read ADC Value.
timebase = adcbuffer[0];
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);
ADCIntClear(ADC1_BASE, 3);
ADCProcessorTrigger(ADC1_BASE, 3); // Trigger the ADC conversion.
while(!ADCIntStatus(ADC1_BASE, 3, false)){} // Wait for conversion to be completed.
ADCIntClear(ADC1_BASE, 3); // Clear the ADC interrupt flag.
ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer); // Read ADC Value.
triglvl = adcbuffer[0];
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);
ADCIntClear(ADC0_BASE, 3);
ADCProcessorTrigger(ADC0_BASE, 3); // Trigger the ADC conversion.
while(!ADCIntStatus(ADC0_BASE, 3, false)){} // Wait for conversion to be completed.
ADCIntClear(ADC0_BASE, 3); // Clear the ADC interrupt flag.
ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer); // Read ADC Value.
xpos = adcbuffer[0];
for (i=0;i<=100;i++)
{
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH7 | ADC_CTL_IE | ADC_CTL_END);
ADCIntClear(ADC0_BASE, 3);
ADCProcessorTrigger(ADC0_BASE, 3); // Trigger the ADC conversion.
while(!ADCIntStatus(ADC0_BASE, 3, false)){} // Wait for conversion to be completed.
ADCIntClear(ADC0_BASE, 3); // Clear the ADC interrupt flag.
ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer); // Read ADC Value.
adcdata1[i] = adcbuffer[0];
ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH6 | ADC_CTL_IE | ADC_CTL_END);
ADCIntClear(ADC1_BASE, 3);
ADCProcessorTrigger(ADC1_BASE, 3); // Trigger the ADC conversion.
while(!ADCIntStatus(ADC1_BASE, 3, false)){} // Wait for conversion to be completed.
ADCIntClear(ADC1_BASE, 3); // Clear the ADC interrupt flag.
ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer); // Read ADC Value.
adcdata2[i] = adcbuffer[0];
}
}
}
Respected Madam/Sir,
I am trying to sample two signals simultaneously using the following code, the inputs would be at PE3 and PE2. I intend to monitor the sampled values, will the CCS Graphs be a good option? I want to observe them in real time because I intend to reconstruct the signal later and perform FFT on it.