Hi guys,
I've choosen for my last university project the amazing Stellaris Launchpad.
Everything goes fine until I've used the integrated ADC:
A simple two steps sequence is used to measure I-V of a device:
Configuration:
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5);
ADCSequenceDisable(ADC0_BASE, 2);
ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH8);
ADCSequenceStepConfigure(ADC0_BASE, 2, 1, ADC_CTL_CH9 | ADC_CTL_IE | ADC_CTL_END );
ADCSequenceEnable(ADC0_BASE, 2);
Call:
while(i < 300)
{
ADCIntClear(ADC0_BASE, 2);
ADCProcessorTrigger(ADC0_BASE, 2);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7, 0);
while(!ADCIntStatus(ADC0_BASE, 2, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 2, ADCvalue);
UARTCharPut(UART0_BASE, (0x3F & (ADCvalue[0] >> 6)));
UARTCharPut(UART0_BASE, (0x40 | (0x3F & ADCvalue[0])));
SysCtlDelay(1000000);
UARTCharPut(UART0_BASE, (0x80 | (0x3F & (ADCvalue[1] >> 6))));
UARTCharPut(UART0_BASE, (0xC0 | (0x3F & ADCvalue[1])));
if (ADCvalue[1] < 20) break;
i ;
}
As you can see, I put ADC datas into UART buffer with a simple two packets communication protocol that marks with a mask the packet (0x3F, 0x40 an so on).
Sometimes, two three times every call, samples of the first channel are changed with the samples of the second channel. It seems that ADC samples first the second channel and then the first one.
Can you help me?
Thank you so much!