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.

Beginner Tiva C Series TM4C123G dev board ADC help

I'm having trouble getting the example code of the adc peripheral, single-ended.c file to work properly on my Tiva C Series TM4C123G dev board.  I want to be able to input an analog signal on pin PD7 from a function generator and output digital data representing the signal to my computer.  The function generator is set to 50 KHz and 500mV.  

I'm able to compile and run the example code on my board but the output is not what it should be.  I'm reading random 0's and 1's on a terminal listening to the serial port on my computer.  I changed SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); and GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_7); to be port D pin 7.  Obviously there is something I'm missing.  What other configuration settings do I need to make this work?  

I'm quite a beginner on this and I need some help on understanding how this ADC works.  I've tried reading from the datasheet on the ADC also.  If someone could explain this or point to a reference that does explain this, it would be very helpful.  Later on I need to implement a version of this that converts 6 analog signals at once.  

Thanks,

Brandon

  • Hi,

    PD7 is by default a NMI pin and to use it you must unlock it first. GPIO chapter in user manual describe how to make that. 

    Also, you may use another pin to test the conversion or search the forum for similar question. Also the PinMux utility can be used to configure this pin for you. Some people do not like this utility - use it as a help and in time you will not need it. Take care in some instances can generate wrong code.

    Petrei

  • I figured why I wasn't reading any data.  The lines below are what I changed:

    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);

    GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_6); //Set PD6 for analog function

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //enabling GPIO port D

    ADC_CTL_CH5 corresponds to channel 5 of the analog inputs which matches up to the pin PD6 which I'm using here.  Before this was set to CH0.  

    I'm reading data now but I know I'm not sampling them correctly which is what I'm working on now.