This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
对于我的应用、我需要使用 ADCA -5通道、ADCB- 2通道和 ADCC-4通道来配置11个 ADC 通道。 同时、我必须一次从所有通道启动 SCO、并将结果存储在循环缓冲器中、从 PWM1触发所有 ADC 模块。 请参阅我的应用代码。
//############################################################################# // // 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 //
有可能吗? 且 SCO 的采样率= 50KH
我提到了上述要求、请帮我实现这一要求。
您好!
"你说什么? 您是否只需要每个 ISR 在频率至少为50kHz 时触发、每次都会产生新的结果? 这听起来是可以实现的。
此致、
本·科利尔