Part Number: TM4C123GE6PM Hi, This is Namha. I have an issue implementing the multi-channel ADC interrupt function. I would like to use two ADC interrupt handlers using timer0 and 1. (ADC sampling frequency :1Mhz) But ADC0SS3IntHandler only works and ADC1SS3IntHandler does not work. ADC initialization and handler code are attached below. Is it a setting problem or another problem? //--------------------------------------- ADC initialization -----------------------------------------------// void ADCInit(void) { //Initialize ADC ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //ADC peripheral ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); //ADC peripheral ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); //Pins used for ADC channels ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0); // *** ADC ROM_ADCReferenceSet(ADC0_BASE,ADC_REF_INT); ROM_ADCReferenceSet(ADC1_BASE,ADC_REF_INT); ROM_ADCSequenceConfigure(ADC0_BASE,3,ADC_TRIGGER_TIMER,0); ROM_ADCSequenceConfigure(ADC1_BASE,3,ADC_TRIGGER_TIMER,3); ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE_NUMBER, 0, ADC_CTL_D | ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ROM_ADCSequenceStepConfigure(ADC1_BASE, ADC_SEQUENCE_NUMBER, 0, ADC_CTL_D | ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END); ROM_ADCSequenceEnable(ADC0_BASE, ADC_SEQUENCE_NUMBER); ROM_ADCSequenceEnable(ADC1_BASE, ADC_SEQUENCE_NUMBER); //ROM_ADCHardwareOversampleConfigure(ADC0_BASE, txLeakageOversamplingNumber); //ROM_ADCHardwareOversampleConfigure(ADC1_BASE, txLeakageOversamplingNumber); // *** Timer0 ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); samplePeriod = ROM_SysCtlClockGet()/(1000*ADC_MAX_SAMPLING_RATE); ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, samplePeriod - 1); // sampling frequency 1Mhz ROM_TimerControlTrigger(TIMER0_BASE, TIMER_A, true); // *** Timer1 ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, samplePeriod - 1); // sampling frequency 1Mhz ROM_TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // *** Interrupts ROM_IntEnable(INT_TIMER0A); ROM_IntEnable(INT_TIMER1A); ROM_TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT); ROM_TimerIntEnable(TIMER1_BASE,TIMER_TIMA_TIMEOUT); ROM_IntEnable(INT_ADC0SS3); ROM_IntEnable(INT_ADC1SS3); ROM_ADCIntEnable(ADC0_BASE,ADC_SEQUENCE_NUMBER); ROM_ADCIntEnable(ADC1_BASE,ADC_SEQUENCE_NUMBER); ROM_IntMasterEnable(); ROM_TimerEnable(TIMER0_BASE,TIMER_A); ROM_TimerEnable(TIMER1_BASE,TIMER_A); } //--------------------------------------------------------- Handler -------------------------------------------------------------------// void Timer0IntHandler(void) { ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); } void Timer1IntHandler(void) { ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); } void ADC0SS3IntHandler(void) { ROM_ADCIntClear(ADC0_BASE,3); ADC0Value[0] = 0; ROM_ADCSequenceDataGet(ADC0_BASE,3,ADC0Value); // Get Data from ADC and store it in ADC1Value adcRawData_0[ADCCurrentIndex_0] = *ADC0Value; ADCCurrentIndex_0++; if(ADCCurrentIndex_0 >= 2048) { ADCCurrentIndex_0 = 0; } } void ADC1SS3IntHandler(void) { ROM_ADCIntClear(ADC1_BASE,3); ADC1Value[0] = 0; ROM_ADCSequenceDataGet(ADC1_BASE,3,ADC1Value); // Get Data from ADC and store it in ADC1Value adcRawData_1[ADCCurrentIndex_1] = *ADC1Value; ADCCurrentIndex_1++; if(ADCCurrentIndex_1 >= 2048) { ADCCurrentIndex_1 = 0; } } Thank you.
↧