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.

TM4C configuring ADC0 and ADC1

Other Parts Discussed in Thread: TM4C1233H6PM
#include <stdint.h>
#include <stdbool.h>
#include "lm4f120h5qr.h"

volatile static uint32_t adcResult = 0;

void ADC0SS3_Handler(void)
{
  adcResult = ADC0->SSFIFO3;
  ADC0->ISC = (1<<3);
}

void ADC1SS3_Handler(void)
{
  adcResult = ADC1->SSFIFO3;
  ADC1->ISC = (1<<3);
}


/*
 * main.c
 */
int main(void) {

	SYSCTL->RCGCADC		= (1 << 0)| (1 << 1);                 // ADC0 was enabled
	SYSCTL->RCGCGPIO	        = (1 << 4);				//  Clock was enabled to Port E in Run mode
	GPIOE->DIR		                = ~(1 << 0);
	GPIOE->AFSEL		        = (1 << 0);				// The alternate function for the corresponding pins were enabled
	GPIOE->DEN		                = ~(1 << 0);				// The digital function for the corresponding pins were disabled
	GPIOE->AMSEL		        = (1 << 0);				// The Analog function for the corresponding pins were disabled

	ADC0->ACTSS		        &= ~(1 << 3);				// ADC0 SS3 was disabled
	ADC1->ACTSS		        &= ~(1 << 3);				// ADC1 SS3 was disabled
	ADC0->EMUX		                = (0xF << 12);				// ADC0 SS3 continuous mode was selected
	ADC1->EMUX		                = (0xF << 12);				// ADC1 SS3 continuous mode was selected
	ADC1->SPC		                = (0x8 << 0);				// ADC1 phase was shifted 180.0
	ADC0->SSMUX3		        = (1 << 0);			        // AIN3 was selected as an anolog input for ADC0
	ADC1->SSMUX3		        = (1 << 0);				// AIN3 was selected as an analog input for ADC1
	ADC0->SSCTL3		        = (0x6 << 0);				// ADC0 sample interrupt was enabled and End of Sequence											
	ADC1->SSCTL3		        = (0x6 << 0);				// ADC1 sample interrupt was enabled and End of Sequence
	ADC0->PC		                = (0x7 << 0);				// ADC0 speed was configured as 1Mbps
	ADC1->PC		                = (0x7 << 0);				// ADC1 speed was configured as 1Mbps
	ADC0->IM		                = (1 << 3);				// ADC0 SS3 interrupt was enabled
	ADC1->IM		                = (1 << 3);				// ADC1 SS3 interrupt was enabled
	ADC0->ACTSS		        = (1 << 3);				// ADC0 SS3 was enabled
	ADC1->ACTSS		       = (1 << 3);				// ADC1 SS3 was enabled
	ADC0->ISC		               = (1 << 3);				// Bit was cleared
	ADC1->ISC		               = (1 << 3);				// Bit was cleared
	while(1){

	}
}

Hi,

I have been working on TM4c1233h6pm and i want to configure adc for 1mbps. I know ı have to use adc0 and adc1 together and i have to shift phase of adc1. When i try to use only adc1 or adc0, it is working but when i try to use adc0 and adc1 together it is not working. Here is my code.

  • Hello Oguz,

    After doing some additional research related to our issue, I have come across additional information that indicates that I may have given you some incorrect information regarding the need to use both ADCs to achieve a sample rate of 1Msps. As stated in the thread located at e2e.ti.com/.../1379421, each of the ADCs is capable of 1MSPS sampling rates so by combining them you would be able to achieve up to 2MSPS.

    In the wiki training, chapter 5 covers the ADC setup and use. It walks through a lab to sample the on chip temperature sensor and uses the default sample rate of 1MSPS. The wiki is located here: processors.wiki.ti.com/.../Getting_Started_with_the_TIVA™_C_Series_TM4C123G_LaunchPad. Hopefully this will allow you to get to the solution you need to get to.

    Also note that using SS0 will allow a deeper FIFO and thus increase the ability to achieve the faster sample rate with time to move results to standard memory.

    here is another post going into a lot of detail on how they achived 1MSPS while collecting a larger amount of samples : e2e.ti.com/.../293737
  • Hi Chuck,

    Thanks for your answer. I understood that from your post it can sample at 2mbps. So my code should be work at 2mbps but my code is not work. i could not find where is my fault. I will use TivaWare library and check one channel ADC's max speed.
  • Hello Oguz,

    Sorry about that. I realized later that I never really addressed your original question in the post as to why ADC1 is not working.

    A quick look at your code didn't reveal any big issues to me, but, obviously, this doesn't mean there isn't something hidden within it that I'm just not seeing at the moment. I would recommend getting 1MSPS working with each of the ADCs separately then combine using separate channels and finally set to the same channel. A step by step approach like this might illuminate an issue that isn't obvious or, at least, point out where the issue lies.
  • Hi again,
    Not only ADC1. when i try to use ADC0 and ADC1 together, ADC0 and ADC1 is not working. I use same input and same sample sequencer.
  • Hello Oguz,

    The use of Phase Shift requires that the two ADC instances be working using the Synchronization mechanism as given by the ADCPSSI register. Secondly, continuous transfer mode generates trigger inside each of the ADC instances and cannot be synchronized. Instead you can use a Timer or Processor Trigger to get the sampler working in phase shift.

    Regards
    Amit
  • Hello Amit,
    Thanks for your answer. Another question came up. Can I use same channel like AIN0? or do I have to use different channel like AIN0 and AIN1?
  • Hello Oguz

    You can use the same channel across the 2 ADC's to get twice the sampling rate with the Phase shift.

    Regards
    Amit
  • İ configured ADC0 and ADC1 both and i could measured analog signal. I want to ask another question. How to I send ADC value to computer via UART. I calculated but there are some problem. UART baudrate is 115200 kbps we can send only 14400 kB in one second but we measure 1Msps so we can not send all data is measured by ADC. Is there any solution for sending large data via UART.
  • And - when this (added) question is answered - might you (again), write, "I want to ask ANOTHER question?"

    This thread is done - resolved - you've not Verified it - and compound that now by shifting from the thread's central topic.

    A new thread - aimed at your NEW issue - is far more appropriate...
  • I have not tested it yet. I want to check ADC speed so I ask another question. if I check and it works fine i will verify it.
  • Hello Oguz

    It cannot be possible that the baud rate is 115200 kbps. It must be 115200 bps. You may change the baud rate to a higher baud rate but the maximum LM4F would be able to perform with is 10 Mbps, which would not be sufficient for 1MSPS with 12 bits. USB can be used but will max out at 12 Mbps (the actual payload throughput is lesser). The only viable option would be USBHS to SSI bridge.

    Regards
    Amit