20路ADC全开,定时触发采集。AD0开了SS0采集8路,优先级0,SS1采集4路,优先级1;AD1开了SS0采集8路,优先级2。
现象是AD0的SS0和AD1的SS0都能进中断,AD0的SS1不进中断。把AD0SS1的优先级设为0,AD0SS0优先级调为1后,情况变为AD0的SS1和AD1的SS0都能进中断,AD0的SS0不进中断。
请问一下是什么原因,谢谢!
初始化代码如下:
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
//config AIN Pin SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5);//AIN0-3,AIN8,AIN9
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);//AIN4-7,AIN12-15,
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeADC(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5);//AIN10¡¢AIN11
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
GPIOPinTypeADC(GPIO_PORTK_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);//AIN16-19
SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);
ADCHardwareOversampleConfigure(ADC0_BASE,16);
ADCHardwareOversampleConfigure(ADC1_BASE,16);
ADCSequenceConfigure(ADC0_BASE, ADC_SS0, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP0, ADC_CTL_CH0);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP1, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP2, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP3, ADC_CTL_CH3);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP4, ADC_CTL_CH4);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP5, ADC_CTL_CH5);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP6, ADC_CTL_CH6);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS0, ADC_STEP7, ADC_CTL_CH7 | ADC_CTL_IE | ADC_CTL_END);//
ADCSequenceEnable(ADC0_BASE, ADC_SS0);
ADCIntClear(ADC0_BASE, ADC_SS0);
ADCIntEnable(ADC0_BASE, ADC_SS0);
IntEnable(INT_ADC0SS0);
ADCSequenceConfigure(ADC0_BASE, ADC_SS1, ADC_TRIGGER_TIMER, 1);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS1, ADC_STEP0, ADC_CTL_CH8);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS1, ADC_STEP1, ADC_CTL_CH9);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS1, ADC_STEP2, ADC_CTL_CH10);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SS1, ADC_STEP3, ADC_CTL_CH11 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, ADC_SS1);
ADCIntClear(ADC0_BASE, ADC_SS1);
ADCIntEnable(ADC0_BASE, ADC_SS1);
IntEnable(INT_ADC0SS1);
ADCSequenceConfigure(ADC1_BASE, ADC_SS0, ADC_TRIGGER_TIMER, 2);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP0, ADC_CTL_CH12);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP1, ADC_CTL_CH13);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP2, ADC_CTL_CH14);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP3, ADC_CTL_CH15);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP4, ADC_CTL_CH16);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP5, ADC_CTL_CH17);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP6, ADC_CTL_CH18);
ADCSequenceStepConfigure(ADC1_BASE, ADC_SS0, ADC_STEP7, ADC_CTL_CH19 | ADC_CTL_IE | ADC_CTL_END);// ADCSequenceEnable(ADC1_BASE, ADC_SS0);
ADCIntClear(ADC1_BASE, ADC_SS0);
ADCIntEnable(ADC1_BASE, ADC_SS0);
IntEnable(INT_ADC1SS0);
中断代码如下:
void ADC0_SS0_IntHandler(){
ADCIntClear(ADC0_BASE, ADC_SS0);
Read_ADC0_SS0_Value();
}
void ADC0_SS1_IntHandler(){
ADCIntClear(ADC0_BASE, ADC_SS1);
Read_ADC0_SS1_Value();
}
void ADC1_SS0_IntHandler(){
ADCIntClear(ADC1_BASE, ADC_SS0);
Read_ADC1_SS0_Value();
}
Susan Yang:
很抱歉,目前手边没有129的开发板,所以不好测试您的代码。
但我之前有保存多通道的代码,您可以参考一下
//***************************************************************************** // // hello.c - Simple hello world example. // // Copyright (c) 2013-2014 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.0.12573 of the EK-TM4C1294XL Firmware Package. // //*****************************************************************************#include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_adc.h" #include "inc/hw_timer.h" #include "driverlib/gpio.h" #include "drivers/pinout.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "driverlib/timer.h" #include "driverlib/uart.h" #include "utils/uartstdio.h"//***************************************************************************** // //! \addtogroup example_list //! <h1>Hello World (hello)</h1> //! //! A very simple ``hello world'' example.It simply displays ``Hello World!'' //! on the UART and is a starting point for more complicated applications. //! //! Open a terminal with 115,200 8-N-1 to see the output for this demo. // //***************************************************************************** uint32_t ui32adcValues[4],ui32Count,ui32adc0Values[1],ui32adc1Values[1],ui32adc2Values[1],ui32adc3Values[1];//***************************************************************************** // // System clock rate in Hz. // //***************************************************************************** uint32_t g_ui32SysClock;//***************************************************************************** // // The error routine that is called if the driver library encounters an error. // //***************************************************************************** #ifdef DEBUG void __error__(char *pcFilename, uint32_t ui32Line) { } #endif//***************************************************************************** // // Configure the UART and its pins.This must be called before UARTprintf(). // //***************************************************************************** void ConfigureADC(void) {SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);SysCtlDelay(10);GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0 );ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_EIGHTH, 30);ADCSequenceStepConfigure(ADC0_BASE,0,0, ADC_CTL_CH0);ADCSequenceStepConfigure(ADC0_BASE,0,1, ADC_CTL_CH1);ADCSequenceStepConfigure(ADC0_BASE,0,2, ADC_CTL_CH2);ADCSequenceStepConfigure(ADC0_BASE,0,3, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);ADCSequenceEnable(ADC0_BASE, 0);ADCSequenceEnable(ADC0_BASE, 1);ADCSequenceEnable(ADC0_BASE, 2);ADCSequenceEnable(ADC0_BASE, 3); }uint32_t WaitAndReadADC(uint32_t *adcValues) {ADCProcessorTrigger(ADC0_BASE,0);// Wait until the sample sequence has completed.while(!ADCIntStatus(ADC0_BASE, 0, false)) { }// Read the value from the ADC.return(ADCSequenceDataGet(ADC0_BASE, 0, adcValues)); }uint32_t WaitAndReadADC1(uint32_t *adcValues) {ADCProcessorTrigger(ADC0_BASE,1);// Wait until the sample sequence has completed.while(!ADCIntStatus(ADC0_BASE, 1, false)) { }// Read the value from the ADC.return(ADCSequenceDataGet(ADC0_BASE, 1, adcValues)); }uint32_t WaitAndReadADC2(uint32_t *adcValues) {ADCProcessorTrigger(ADC0_BASE,2);// Wait until the sample sequence has completed.while(!ADCIntStatus(ADC0_BASE, 2, false)) { }// Read the value from the ADC.return(ADCSequenceDataGet(ADC0_BASE, 2, adcValues)); }uint32_t WaitAndReadADC3(uint32_t *adcValues) {ADCProcessorTrigger(ADC0_BASE,3);// Wait until the sample sequence has completed.while(!ADCIntStatus(ADC0_BASE, 3, false)) { }// Read the value from the ADC.return(ADCSequenceDataGet(ADC0_BASE, 3, adcValues)); }//***************************************************************************** // // Print "Hello World!" to the UART on the Intelligent UART Module. // //***************************************************************************** int main(void) {//// Run from the PLL at 120 MHz.//g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);//// Configure the device pins.//PinoutSet();//// Enable the GPIO pins for the LED D1 (PN1).//ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);//// Initialize the UART.//ConfigureADC();//// Hello!////// We are finished.Hang around flashing D1.//while(1){//// Turn on D1.////LEDWrite(CLP_D1, 1);//ui32Count = WaitAndReadADC0(ui32adc0Values);//ui32Count = WaitAndReadADC1(ui32adc1Values);//ui32Count = WaitAndReadADC2(ui32adc2Values);ui32Count = WaitAndReadADC(ui32adcValues);//// Delay for a bit.//// SysCtlDelay(g_ui32SysClock / 10 / 3);//// Turn off D1.////LEDWrite(CLP_D1, 0);//// Delay for a bit.//cank// SysCtlDelay(g_ui32SysClock / 10 / 3);} }参考链接为 https://e2e.ti.com/support/microcontrollers/other/f/908/t/476214#pi320995=1