This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In an ADC program(single ended given by TI). I choose channnel 11 ie(pin PB5) to give input 3.3v from the board itself.i got adc reading 4095 i lso give same input to channel0(PE3 pin) i got o/p as 2235.why did it responded like this.my code is given below
ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH10 | ADC_CTL_IE |
ADC_CTL_END);
frequency set as 20MHZ
GEORGE DAVIS C said:i also give same input to channel 0 (PE3 pin)
Perhaps because, "ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH10 | ADC_CTL_IE | ADC_CTL_END);" is not channel 0 ! (we helpers must work w/the data you provide...)
Devil in the details... (should your post be typed in error - check that suspect ADC channel is not one of the 2 pins "cross connected" - your board. Schematic will reveal)
Use of full-scale input level (3V3) is not, "best practice." Suggest instead 10%, 50%, 90% (of full scale 3V3) as a better input level. Use of such "in range" levels will prove more meaningful & useful...
Thank you for your response and guidance.
clarifications of the above question
code mentioned was "ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH11 | ADC_CTL_IE | ADC_CTL_END);"
Didn't selected channel 0 at all, even then while giving i/p to it, it is responding,expecting it to not to respond.
I tested all the 12 channels like this.In most of the channels, found channel 0 responding like this.
Is channel 0(PE3 PIN) is enabled by default? While channel 0 is selected it shows correct reading 4095 for 3.3V and very low value when shorting to ground.
I will definitely check this by giving different i/p levels.
Couldn't able to find PE3 & PB5 pins cross connected in the schematics(spmu289a)
Could you please give further help, it will be grateful.
Have neither that board nor recent read - that MCU's data.
Perhaps brief posting of your ADC code - especially set-up & config. of ADC - will aid.
Usually - the GPIO chapter of MCU manual details any "special handling" of GPIO Ports/Pins. I cannot recall PE3 nor PB5 falling under that category - but ours is different MCU (still Stellaris) M4.
I do note that PE3 & PE2 - on our Stellaris M4 - are reasonably unique in that they include no, "alternate functions." (thus they may serve as GPIO or ADC - only)
Always wise to check that unexpected/unwanted "other signal routings" do not "spoil" your ADC inputs. Appears that you've checked for GPIO "loop-back" - but I'd carefully review schematic (and board) on any "misbehaved" channel. Fact that most channels perform to expectation - points to your proper set-up/config - however a single misplaced parameter may wreak havoc...
Brief (only ADC essentials) code post seems worthwhile... (you may copy the relevant ADC set-up/config code first into Notepad - subsequent "paste" here will then display nicely.)
hai
ADC code used is given below
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"
void
InitConsole(void)
{
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
//
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
//
UARTStdioInit(0);
}
int
main(void)
{
//
unsigned long ulADC0_Value[1];
SysCtlClockSet(SYSCTL_SYSDIV_10| SYSCTL_USE_PLL| SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
//
InitConsole();
//
//
UARTprintf("ADC ->\n");
UARTprintf(" Type: Single Ended\n");
UARTprintf(" Samples: One\n");
UARTprintf(" Update Rate: 250ms\n");
UARTprintf(" Input Pin: AIN0/PE7\n\n");
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeADC(GPIO_PORTB_BASE, GPIO_PIN_5);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH11 | ADC_CTL_IE |
ADC_CTL_END);
//
ADCSequenceEnable(ADC0_BASE, 3);
//
ADCIntClear(ADC0_BASE, 3);
while(1)
{
//
ADCProcessorTrigger(ADC0_BASE, 3);
//
//
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
ADCIntClear(ADC0_BASE, 3);
//
ADCSequenceDataGet(ADC0_BASE, 3, ulADC0_Value);
UARTprintf("AIN0 = %4d\r", ulADC0_Value[0]);
SysCtlDelay(SysCtlClockGet() / 12);
}
}
I find nothing seriously wrong with code listed. Would be safer to:
ADCSequenceDisable(ADC0_BASE, 3); prior to...
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
And you UARTprintf "AIN0" - when PB5 is - and remains - ADC_CTL_CH11. While sloppy - should not impact your code.
Is it possible - or likely - that you provided an input signal beyond the 3V3 rating of this single, problematic ADC channel?
I HAVE GIVEN I/P SIGNAL OF 5.2V(VBUS+) FROM THE BOARD TO ALL CHANNELS, BUT CHANNEL 0 ONLY RESPONDED LIKE THIS.
NO SIGNAL GREATER THAN 5.2 V GIVEN.
Hi,
Before doing something with unwanted consequences it is recommended to read, understand and memorize at least the electrical characteristics - for ADC it is mandatory the input is less than VDDA (3.3V on your board). Although the ADC input has some internal circuitry to protect it against over/under-voltages, it is recommended to use a small .5...1k resistor in series with the ADC pin, just to protect the micro (at least in testing phase - did you done such thing?).
Please follow cb1 advise to apply a much smaller voltage - use a potentiometer - the code looks OK - maybe what I suggest is to add this line
ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);
Your micro starts with external reference set - but it is wise to check the ADCCTL register to see that - anyway this line will not harm.
Petrei