Tool/software: Code Composer Studio
Hi together,
i want to convert 3 analog inputs over 1 sequencer with the following settings.
When I debug my code, than it look like I have a problem with the FIFO.
With the first Interrupt there were stored 3 values in the “adcBuffer2” variable. And in the next interrupts the adcBuffer2 stored 6 values. I don’t understand why this happened.
Have you any idears?
// // Library Generals // #include "stdbool.h" #include <stdio.h> #include <stdint.h> // // Library TivaWare // #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/adc.h" #include "inc/tm4c1294ncpdt.h" #include "inc/hw_memmap.h" // // Library own // #include "adc2.h" // // Globale Variablen // uint32_t adcBuffer2[30]; uint32_t adcGetValues; // // Interrupt Handler ADC0SS0 // void ADC0IntHandler(void) { uint32_t test = 0; // Clear interrupt Flag ADCIntClear(ADC0_BASE, 0); ADCSequenceDataGet(ADC0_BASE, 0, adcBuffer2); adcGetValues=1; } void main(void) { adcGetValues=0; uint32_t sysclock_read=0; sysclock_read=SysCtlClockFreqSet(SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000); printf("Systemclock is set to: %d\n", sysclock_read); // ADC Init adc2_init(); IntPrioritySet(INT_ADC0SS0, 0x00); // // ADC0SS0 Interrupt source // ADCIntRegister(ADC0_BASE, 0, ADC0IntHandler); // // Register Interrupt to NVIC // IntRegister(INT_ADC0SS0, ADC0IntHandler); // // ADC0 enable // ADCIntEnable(ADC0_BASE, 0); // // Interrupt ADC0SS0 enable // IntEnable(INT_ADC0SS0); // // Enable Global Interrupts // IntMasterEnable(); // // Sequencer enable // ADCSequenceEnable(ADC0_BASE, 0); while(1){ if (adcGetValues==1) { ADCSequenceDisable(ADC0_BASE, 0); ADCIntDisable(ADC0_BASE, 0); IntDisable(INT_ADC0SS0); //ADCSequenceDisable(ADC0_BASE, 0); /* printf("ADC Value1: %d\n", adcBuffer2[0]); printf("ADC Value2: %d\n", adcBuffer2[1]); printf("ADC Value3: %d\n", adcBuffer2[2]); */ adcGetValues = 0; ADCIntEnable(ADC0_BASE, 0); IntEnable(INT_ADC0SS0); ADCSequenceEnable(ADC0_BASE, 0); } } }
#include <stdint.h> #include <stdbool.h> #include <stdio.h> #include "inc/tm4c1294ncpdt.h" #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/comp.h" #include "func.h" adc2_init(){ uint32_t adcClock=0, adcDiv=0; // // Enable the ADC0 peripheral // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); wait(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); wait(); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); // // Configure the ADC to use PLL at 480 MHz with Full rate devided by 30 to get 16 MHz // ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 30); ADCSequenceDisable(ADC0_BASE, 0); // // Read the current ADC configuration // adcClock=ADCClockConfigGet(ADC0_BASE, &adcDiv); printf("ADC clock is: 0x%x, div: 0x%x\n", adcClock, adcDiv); // // Hardware averageing: by a faktor of 2 -> 2,4,8,16,32,64 // ADCHardwareOversampleConfigure(ADC0_BASE, 0); // // ADC voltage-lvl reference set to intern // ADCReferenceSet(ADC0_BASE, ADC_REF_INT); // // ADC Sequencer config: Source ADC0, Sequencer 0, Trigger: always, priority: 0 // ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS, 0); // // ADC Sequencer step // 1. Source-ADC -> ADC0_BASE // 2. Source-Sequencer -> 0 // 3. Sample-Value depends in the depth of the FIFO, by Sequencer 0 it is up to 7 (0-7) // 4. Config-> select input-channel AINx, interrupt specification // ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1); ADCSequenceStepConfigure(ADC0_BASE, 0, 2, (ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END)); }