Tool/software: Code Composer Studio
Good afternoon fellow programmers, I have been trying to develop an ADC program the last few days, so I stumbled upon a problem. I have configured both ADC0 and ADC1 with sequence number 2 and I would like to read separate informations i.e.: Pins PK3 to PK1 reading and sending its values to ADC1 and Pins PE3 to PE1 reading and sending values to ADC0. I've already configured the pins, but when I call the ADCSequenceDataGet (Im using 2 different uint32 variables to store the infos) the same information is on both ADC0 and ADC1 channels. Is there a way to solve my problem? Im going to attach the code.
//***************************************************************************** // // uart_echo.c - Example for reading data from and writing data to the UART in // an interrupt driven fashion. // // Copyright (c) 2013-2017 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.4.178 of the EK-TM4C1294XL Firmware Package. // //***************************************************************************** #include <stdint.h> #include <stdbool.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" #include "driverlib/adc.h" #include "driverlib/timer.h" #include <math.h> //***************************************************************************** // //! \addtogroup example_list //! <h1>UART Echo (uart_echo)</h1> //! //! This example application utilizes the UART to echo text. The first UART //! (connected to the USB debug virtual serial port on the evaluation board) //! will be configured in 115,200 baud, 8-n-1 mode. All characters received on //! the UART are transmitted back to the UART. // //***************************************************************************** //**************************************************************************** // // 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 //***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** char y; char x[6] = "GPRMC,"; int k=0; int j=0; int cont=0; int flagcheck=0; int flag=0; int codvalido = 0; char buffer[62]=""; int indices[12]; int cont2=0; int utcgeral=0; int hora=0; int min=0; int seg=0; int datageral=0; int dia=0; int mes=0; int ano=0; //int unix=0; //int ydia=0; uint32_t ui32Value[4]; uint32_t ui32Value2[4]; void Timer0IntHandler(void) { ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ADCProcessorTrigger(ADC0_BASE, 2); while(!ADCIntStatus(ADC0_BASE, 2, false)) { } ADCSequenceDataGet(ADC0_BASE, 2, &ui32Value); ADCProcessorTrigger(ADC1_BASE,2); while(!ADCIntStatus(ADC1_BASE, 2, false)) { } ADCSequenceDataGet(ADC1_BASE,2, &ui32Value2); flagcheck=1; } void UARTGPS(void) { uint32_t ui32Status; // // Get the interrrupt status. // ui32Status = ROM_UARTIntStatus(UART3_BASE, true); // // Clear the asserted interrupts. // ROM_UARTIntClear(UART3_BASE, ui32Status); // // Loop while there are characters in the receive FIFO. // while(ROM_UARTCharsAvail(UART3_BASE)) { y = UARTCharGetNonBlocking(UART3_BASE); UARTCharPut(UART0_BASE,y); if(flag==1) { buffer[cont+1]=y; cont++; if (buffer[cont-1]==',') { indices[cont2]=cont-1; cont2++; } if(buffer[cont-1]=='*') { indices[11]=cont-1; flag=0; cont=0; for(j=0;j<6;j++) { utcgeral = utcgeral+(((buffer[(5-j)])-48)*pow(10,j)); } hora = utcgeral/10000; min = ((utcgeral%10000)/100); seg = utcgeral%100; utcgeral = 0; for(k=48;k<54;k++) { datageral = datageral + (((buffer[101-k])-48)*pow(10,(k-48))); } dia = datageral/10000; mes = ((datageral%10000)/100); ano = datageral%100; datageral = 0; } } if(k==6) { flag = 1; k=0; buffer[cont]=y; } if(codvalido==1) { if(x[k]==y) { k++; } else { codvalido=0; k=0; } } if (y=='$') { codvalido=1; } } } void ConfigureUART (void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_GPIOPinConfigure(GPIO_PA4_U3RX); ROM_GPIOPinConfigure(GPIO_PA5_U3TX); ROM_GPIOPinConfigure(GPIO_PA0_U0RX); ROM_GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_0 | GPIO_PIN_1); ROM_UARTConfigSetExpClk(UART3_BASE, g_ui32SysClock, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); ROM_UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); } int main(void) { g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); ROM_IntMasterEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); ROM_TimerLoadSet(TIMER0_BASE, TIMER_A,g_ui32SysClock); // Setando pinos da Porta E como ADC GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3); GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_2); GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_1); // Setando pinos da porta K como ADC GPIOPinTypeADC(GPIO_PORTK_BASE,GPIO_PIN_3); GPIOPinTypeADC(GPIO_PORTK_BASE,GPIO_PIN_2); GPIOPinTypeADC(GPIO_PORTK_BASE,GPIO_PIN_1); //adc 0 ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH2); ADCSequenceStepConfigure(ADC0_BASE, 2, 1, ADC_CTL_CH1); ADCSequenceStepConfigure(ADC0_BASE, 2, 2, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0); ADCSequenceEnable(ADC0_BASE, 2); // adc 1 ADCSequenceConfigure(ADC1_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC1_BASE, 1, 0, ADC_CTL_CH2); ADCSequenceStepConfigure(ADC1_BASE, 1, 1, ADC_CTL_CH1); ADCSequenceStepConfigure(ADC1_BASE, 1, 2, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0); ADCSequenceEnable(ADC1_BASE, 1); ROM_IntEnable(INT_TIMER0A); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ROM_TimerEnable(TIMER0_BASE, TIMER_A); ConfigureUART(); ROM_IntEnable(INT_UART3); ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT); while(1) { } }