hello,
For my application I need to configure 11 ADC channels using ADCA -5 channels, ADCB- 2 Channels and ADCC-4 channels. meanwhile i have to start SCO from all channels at a time and store results in circular buffer, triggering from PWM1 for all the ADC modules? please refer my application code.
//#############################################################################
//
// FILE: lab_main.c
//
// TITLE: C2000 Academy Lab Startup Project
//
//
// This example is a startup project for C2000 Academy lab.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Included Files
//
#include "board.h"
//
// Function Declarations
//
__interrupt void INT_myADCA_1_ISR(void);
__interrupt void INT_myADCB_2_ISR(void);
__interrupt void INT_myADCC_3_ISR(void);
void main(void)
{
// CPU Initialization
Device_init();
Interrupt_initModule();
Interrupt_initVectorTable();
// Configure the GPIOs/ADC/PWM through SysConfig generated files
Board_init();
// Enable global interrupts and real-time debug
EINT;
ERTM;
// Main Loop
while(1){}
}
// Define circular buffer lengths
#define ADC_BUF_LEN 50
static volatile uint16_t LED_count = 0;
// Circular buffers
uint16_t AdcBuf1[ADC_BUF_LEN];
uint16_t AdcBuf2[ADC_BUF_LEN];
uint16_t AdcBuf3[ADC_BUF_LEN];
// Pointers for circular buffers
uint16_t *AdcBufPtr1 = AdcBuf1;
uint16_t *AdcBufPtr2 = AdcBuf2;
uint16_t *AdcBufPtr3 = AdcBuf3;
// Debug toggles
#define DEBUG_TOGGLE_1 1
#define DEBUG_TOGGLE_2 1
#define DEBUG_TOGGLE_3 1
// ADC ISR for reading 5 results
interrupt void INT_myADCA_1_ISR(void)
{
*AdcBufPtr1++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC0);
*AdcBufPtr1++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC1);
*AdcBufPtr1++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC2);
*AdcBufPtr1++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC3);
*AdcBufPtr1++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC4);
if (AdcBufPtr1 == (AdcBuf1 + ADC_BUF_LEN))
{
AdcBufPtr1 = AdcBuf1;
}
if (DEBUG_TOGGLE_1 == 1)
{
GPIO_togglePin(myGPIOToggle1);
}
if(LED_count++ > 25000) // Toggle slowly to see the LED blink
{
GPIO_togglePin(myBoardLED0_GPIO); // Toggle the pin
LED_count = 0; // Reset the counter
}
Interrupt_clearACKGroup(INT_myADCA_1_INTERRUPT_ACK_GROUP);
ADC_clearInterruptStatus(myADCA_BASE, ADC_INT_NUMBER1);
}
// ADC ISR for reading 2 results
interrupt void INT_myADCB_2_ISR(void)
{
*AdcBufPtr2++ = ADC_readResult(myADCB_RESULT_BASE, myADCB_SOC0);
*AdcBufPtr2++ = ADC_readResult(myADCB_RESULT_BASE, myADCB_SOC1);
if (AdcBufPtr2 == (AdcBuf2 + ADC_BUF_LEN))
{
AdcBufPtr2 = AdcBuf2;
}
if (DEBUG_TOGGLE_2 == 1)
{
GPIO_togglePin(myGPIOToggle2);
}
if(LED_count++ > 25000) // Toggle slowly to see the LED blink
{
GPIO_togglePin(myBoardLED0_GPIO); // Toggle the pin
LED_count = 0; // Reset the counter
}
Interrupt_clearACKGroup(INT_myADCB_2_INTERRUPT_ACK_GROUP);
ADC_clearInterruptStatus(myADCB_BASE, ADC_INT_NUMBER2);
}
// ADC ISR for reading 4 results
interrupt void INT_myADCC_3_ISR(void)
{
*AdcBufPtr3++ = ADC_readResult(myADCC_RESULT_BASE, myADCC_SOC0);
*AdcBufPtr3++ = ADC_readResult(myADCC_RESULT_BASE, myADCC_SOC1);
*AdcBufPtr3++ = ADC_readResult(myADCC_RESULT_BASE, myADCC_SOC2);
*AdcBufPtr3++ = ADC_readResult(myADCC_RESULT_BASE, myADCC_SOC3);
if (AdcBufPtr3 == (AdcBuf3 + ADC_BUF_LEN))
{
AdcBufPtr3 = AdcBuf3;
}
if (DEBUG_TOGGLE_3 == 1)
{
GPIO_togglePin(myGPIOToggle3);
}
if(LED_count++ > 25000) // Toggle slowly to see the LED blink
{
GPIO_togglePin(myBoardLED0_GPIO); // Toggle the pin
LED_count = 0; // Reset the counter
}
Interrupt_clearACKGroup(INT_myADCC_3_INTERRUPT_ACK_GROUP);
ADC_clearInterruptStatus(myADCC_BASE, ADC_INT_NUMBER3);
}
//
// End of File
//
will it be possible? and sampling rate of SCO= 50KH
I mentioned the requirement above, kindly assist me please to achieve this.