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.

CCS / EK-TM4C123GXL: EK-TM4C123GXL

Part Number: EK-TM4C123GXL

Tool/software: Code Composer Studio

Thank you for sharing your code, I have downloaded and studied it.

I have a few doubts about it and I will be pleased if you help me with them. To test your code, I connect a potentiometer in PE2, varying from 0V (GND) to 3.3V (GPIO of the board). 

1)I understood that the ADC_Outs are the vectors that are receiving data from the ADC. But I could not understand the pattern of the numbers. The majority of them are ZERO even if PE2 is 3.3V. I thought it should be 4096 = 2^12(number of bit of ADC0). Could you explain to me the math?

2) Why have you used many zeros as 0u. What is this "u"  for? Can I remove it?

3) I noticed some functions of driverlib (TivaCSeries)with the prefix MAP_. Why have you done that? Can I remove it?

My aim is to pick a voltage signal from a GPIO. The real project is a filter but for tests, I have connected a potentiometer in PE2 (pin of ADC0). I want to grab the values in a choosing rate and make operations with them. 

For example, my potentiometer is set in 3.3V. I want to grab this vector (for me the numbers of the vector should be at least similar) and make operations with it. For instance, I can multiple it by 2 or multiple the vector by a constant matrix.

I am a beginner with microcontrollers, so if you have other tips or materials to help me, it will be of great value.

I am looking forward to your reply. If you prefer a different channel of communication, I am also open.

Thanks!

  • Hi Luis,

      First of all, with the newly released TivaWare (version 2.2.0.295) there is a new example called adc_udma_pinpong which does the same thing as the the other example uploaded by Bob. By the way, Bob is out of office. I ran the example and below is what I got taking a screenshot of the output. This example uses PE0 as the ADC input. You can change it to your liking. I connect PE0 to 3.3V and I get 4095 as the converted value which is correct.

    Luis Gustavo Ganimi said:
    1)I understood that the ADC_Outs are the vectors that are receiving data from the ADC. But I could not understand the pattern of the numbers. The majority of them are ZERO even if PE2 is 3.3V. I thought it should be 4096 = 2^12(number of bit of ADC0). Could you explain to me the math?

      The code is trying to take 64 samples of the input and then average them. 

    Luis Gustavo Ganimi said:
    2) Why have you used many zeros as 0u. What is this "u"  for? Can I remove it?

    'u' means unsigned. You can remove if you want but why?

    Luis Gustavo Ganimi said:

    3) I noticed some functions of driverlib (TivaCSeries)with the prefix MAP_. Why have you done that? Can I remove it?

    Read the rom_map.h file and you will get a better understanding. Basically, if there is function xyz() already available in the ROM then the MAP_xyz() will call the ROM_xyz() or otherwise, call the xyz() instead. Calling the same API/function in the ROM will save you flash spaces and the execution will be a little bit faster. But if you want to debug the code it will be more difficult as there is no symbol. You can change to xyz() while you are debugging your software. Once you are done with your development you can decide if you want to improve the efficiency by changing to MAP_. 

  • Thank you for the quick answer! But I still have some questions:

    1)I am using Bob's code and the pin is PE2, right? I concluded it because of this line: GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);

    2)I have connected the pins like the picture shows. Is it correct? But the average is from 10 to 14(very often 14). I do not get it. Just to confirm, the relation 3.3V --- 4095 is correct? So if the signal was 1.5V would be 1861?

    2)You said that the code is taking 64 samples of the input and average them. I would like to know the frequency of it? Just one of theses 64 samples is done in 62.5us, right? I concluded this because of this line:

    MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, MAP_SysCtlClockGet()/16000 -1). 

    The "void ADCseq0Handler()" is called every 1 sample? But only runs inside the Ifs every 64 samples? Both sentences are correct ?

    3)I have already read material about this PING-PONG process but it is not as clear as I wanted. The ADC is taking a sample each 62.5us, then it sends these samples to a vector THROUGH uDMA, right? The first 64 samples go to PING vector (ADC_out1), then the next 64 samples go to PONG vector (ADC_Out2) and this process keeps exchanging. This explanation is correct?

    4)What is the difference between MAP_function and ROM _function? I knew the benefits of ROM_functions because of the labs that Texas provided, but I have not seen any MAP_functions.

    5)Thanks a lot for the explanation of the 0u, it was only for curiosity. I am going not to change it.

  • Luis Gustavo Ganimi said:
    1)I am using Bob's code and the pin is PE2, right? I concluded it because of this line: GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);

    PE2 is correct in Bob's uploaded program. But as I suggested in my last reply, use the TivaWare example adc_udma_pinpong  instead. The one that was uploaded to your original post did not work for me. The average shown on the display is 255 instead of 4095. These two examples are pretty much the same except that the adc_udma_pinpong is included in the latest TivaWare release as an official example. 

    2)You said that the code is taking 64 samples of the input and average them. I would like to know the frequency of it? Just one of theses 64 samples is done in 62.5us, right? I concluded this because of this line:

     This example uses the Timer module to generate periodic trigger to the ADC every 62.5uS as in below configuration. You can change it to your requirement.

    //
    // Set ADC sampling frequency to be 16KHz i.e. every 62.5uS.
    //
    TimerLoadSet(TIMER0_BASE, TIMER_A, (SysCtlClockGet()/16000) - 1);

    Luis Gustavo Ganimi said:
    The "void ADCseq0Handler()" is called every 1 sample? But only runs inside the Ifs every 64 samples? Both sentences are correct ?

    Correct.

    Luis Gustavo Ganimi said:
    3)I have already read material about this PING-PONG process but it is not as clear as I wanted. The ADC is taking a sample each 62.5us, then it sends these samples to a vector THROUGH uDMA, right? The first 64 samples go to PING vector (ADC_out1), then the next 64 samples go to PONG vector (ADC_Out2) and this process keeps exchanging. This explanation is correct?

    Correct.

    Luis Gustavo Ganimi said:
    4)What is the difference between MAP_function and ROM _function? I knew the benefits of ROM_functions because of the labs that Texas provided, but I have not seen any MAP_functions.

    Did you read the rom_map.h?  Here is one example. If there is already a ROM_ADCProcessorTrigger  API then the MAP_ADCProcessorTrigger just becomes the ROM_ADCProcessorTrigger  or otherwise the MAP_ADCProcessorTrigger is the ADCProcessorTrigger.

    #ifdef ROM_ADCProcessorTrigger
    #define MAP_ADCProcessorTrigger \
    ROM_ADCProcessorTrigger
    #else
    #define MAP_ADCProcessorTrigger \
    ADCProcessorTrigger