Hi All,
This is driving me crazy and I've seen people mention Errata notes on this on a few threads but I can't get my head around the work around really.
(Ref. Tiva Errata Notes ADC#03 .. Sounds like my issue anyway !)
I am trying to use a EK-TM4C123GXL to do some simple single shot ADC conversions. I have done this on numerous other TI boards before with no issue (using both direct reg access and Tiva/StellarisWare API calls).
I have boiled my code down to the simplest form I can think of and it still gets jammed at the ADCIntStatus() call.
My Code is as follows (pretty much textbook ADC example)
ADC0 using PE1 (AIN2) on Sequence
/* Set the System Clock Frequency */ SysCtlClockSet(SYSCTL_SYSDIV_2|SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ); /* Global interrupt Enable */ IntMasterEnable(); //Clock gate enable for ADC0 SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); /* Using PE1 so we have to clock gate the PORTE peripheral */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); /* Set PE1 as an ADC input pin */ GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_1); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); int i=0; ADCSequenceDisable(ADC0_BASE, 3);//Good idea to disable before step config for(i=0;i<150;i++); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH2); ADCSequenceEnable(ADC0_BASE, 3); for(i=0;i<150;i++); //Enable ADC sequence int ADCIntEnable(ADC0_BASE,ADC_INT_SS3); //Enable int source ADCIntEnableEx(ADC0_BASE,ADC_INT_SS3);//Don't think is strictly needed /* Enable the NVIC to recognise the ints */ SysCtlIntEnable(INT_ADC0SS3); //Trigger ADC ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { //Loop until ADC process completes and generates raw interrupt } uint32_t ui32Value; ADCSequenceDataGet(ADC0_BASE, 3, &ui32Value); while(1) { //Loop Forever }
But it always hangs at the ADCIntStatus() call.
I can only assume I am doing something very silly but I can't see it. Any ideas ? All help appreciated
Notes:
>I am using CCS
> I have tried most of the above with direct reg accesses and get the same result. I have tried changing the sequence and input pin with same result.
Am I correct in saying , that in the uC data sheet in the ADC section, when listing the signals (See page 802 of the TM4C123GH6PM Data sheet) that the AINn (where 'n' is a number) is the number you use for the channel in the step configuration call.
e.g. PE1 is AIN2 n the data sheet. so we use CH2 ? see below
ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH2);
Thanks, I'm sure this is a silly issue as I've said
Jay