Hi,
I am using the Tiva C series Launchpad to sample two channels and to display it in a GLCD for an oscilloscope project. I configured two ADC modules and initiated the sampling. The code is shown below. I will be needing only the MSB 6 bits of the ADC value. So I use a separate 8 bit word to store the values. But I am not able to display anything on the GLCD. When I try giving default values for the adcdata, I get a perfect sine wave. Please help me out.
void PortFunctionInit(void){ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Port A for control pins SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // Port B for data pins SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // For ADC pins SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Port E for ADC inputs SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Port F for LED lights SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // The ADC0 peripheral must be enabled for use. SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); // The ADC1 peripheral must be enabled for use. GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0); // Configuring PD0 as ADC input (channel 1) CH7 ADC0 GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1); // Configuring PD1 as ADC input (channel 2) CH6 ADC1 GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2); // Configuring PD2 as ADC input (time base) CH5 GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3); // Configuring PD3 as ADC input (trigger level) CH4 GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0); // Configuring PE0 as ADC input (X-POS) CH3 } int main(void) { uint8_t adc0data[128],adc1data[128]; uint32_t timebase,triglvl,xpos,adcbuffer[1],i; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //20 MHz clock PortFunctionInit(); GLCD_Initalize(); GLCD_ClearScreen(); uint8_t sinwav[128] = {0x20,0x25,0x2A,0x2F,0x33,0x37,0x3A,0x3C,0x3E,0x3F,0x3F,0x3E,0x3C,0x3A,0x36,0x32,0x2E,0x29,0x24,0x1F,0x19,0x14,0x10,0x0B,0x08,0x05,0x02,0x01,0x00,0x00,0x01,0x03,0x06,0x09,0x0D,0x12,0x17,0x1C,0x21,0x26,0x2B,0x30,0x34,0x38,0x3B,0x3D,0x3E,0x3F,0x3F,0x3D,0x3B,0x39,0x35,0x31,0x2C,0x28,0x22,0x1D,0x18,0x13,0x0E,0x0A,0x07,0x04,0x02,0x00,0x00,0x00,0x02,0x04,0x07,0x0A,0x0F,0x13,0x18,0x1D,0x23,0x28,0x2D,0x31,0x35,0x39,0x3C,0x3E,0x3F,0x3F,0x3E,0x3D,0x3B,0x38,0x34,0x30,0x2B,0x26,0x21,0x1C,0x16,0x12,0x0D,0x09,0x06,0x03,0x01,0x00,0x00,0x01,0x02,0x05,0x08,0x0C,0x10,0x15,0x1A,0x1F,0x24,0x29,0x2E,0x33,0x36,0x3A,0x3C,0x3E,0x3F,0x3F,0x3E,0x3C,0x3A,0x37}; /*while(1) { GLCD_ClearScreen(); for(i=64;i<128;i++) GLCD_SetPixel(i,63-sinwav[i-64]); for(i=0;i<63;i++) GLCD_SetPixel(i,63-sinwav[i+64]); for(i=0;i<1000;i++) SysCtlDelay(1000); }*/ ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 2); ADCSequenceEnable(ADC0_BASE, 3); ADCSequenceEnable(ADC1_BASE, 3); ADCIntClear(ADC0_BASE, 2); ADCIntClear(ADC0_BASE, 3); ADCIntClear(ADC1_BASE, 3); while(1) { ADCIntClear(ADC0_BASE, 2); ADCProcessorTrigger(ADC0_BASE, 2); // Trigger the ADC conversion. while(!ADCIntStatus(ADC0_BASE, 2, false)){} // Wait for conversion to be completed. ADCIntClear(ADC0_BASE, 2); // Clear the ADC interrupt flag. ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer); // Read ADC Value. timebase = adcbuffer[0]; for (i=0;i<128;i++) { ADCIntClear(ADC0_BASE, 3); ADCIntClear(ADC1_BASE, 3); ADCProcessorTrigger(ADC1_BASE, (3|ADC_TRIGGER_WAIT)); // Put ADC-1 in Trigger Wait ADCProcessorTrigger(ADC0_BASE, (3|ADC_TRIGGER_SIGNAL)); // Put ADC-0 in Global Trigger while(!ADCIntStatus(ADC0_BASE, 3, false)){} // Wait for conversion to be completed. ADCIntClear(ADC0_BASE, 3); // Clear the ADC interrupt flag. ADCIntClear(ADC1_BASE, 3); // Clear the ADC interrupt flag. ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer); // Read ADC Value. adc0data[i] = adcbuffer[0]>>8; ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer); // Read ADC Value. adc1data[i] = adcbuffer[0]>>8; } GLCD_ClearScreen(); for(i=0;i<128;i++) { GLCD_SetPixel(i,adc0data[i]); GLCD_SetPixel(i,adc1data[i]); } } }
Regarding the code, the array sinwav is just a sample waveform which will be used by the commented code right next to it to check if a sine wave can be displayed on the GLCD.
Thanks in advance.