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.

BeagleBone Black + JTAG (xds100v2) + StarterWare + Analog Inputs

Hey,

I have a BeagleBone Black connected with Code Composer Studio v5.5 through a JTAG, xds100v2. I'm using Starterware v02.00.01.01, I've already tested the gpioLEDBlink example and it is working correctly. The thing is, I want to use the analog inputs A0 to A7, and I really want to know if it is really possible to do it. In the folder Starterware it only have examples for evm335x and evmsk335x and I would like to be certain if I can get to work with the ADCs using Starterware. If so, what sould I do? I would be really great if someone answered my question for me to get started on my work. Thank you for your attention.

Best regards,

Luciano.

  • Hi Luciano,

    You can use the ADC on beaglebone black. The AIN0 to AIN6 analog input pins are brought out on P9 expansion header. To work on ADC you need to enable the functional clocks to the module. Please use TSCADCModuleClkConfig API defined in platform/evmskAM335x/tscAdc.c as reference for enabling the clocks of ADC IP. You can reuse the DAL APIs defined in drivers/tsc_adc.c for configuring the IP.

    The example application defined for evmAM335x and evmskAM335x can be used as refernce for your usecase.

    Regards

    Anant Pai

  • Hey Anant Pai,

    Thanks for answering.

    Pardon my ignorance, but could you explain how to do it? For example, what I need is to copy these files into to the respective folders, like copying the "tscAdc.c" file from platform/evmskAM335x to platform/beaglebone and build it again, then build my program?

    What do you mean by reusing the DAL APIs defined in drivers? The file "tsc_adc.c" is already in the project. Do I have to change something?

    What new libraries should I include besides the ones that are at adcVoltageMeasure project?

    I am reusing the gpioLEDBlink (beaglebone) example combined with adcVoltageMeasure (evmAM335x) because I want to see the LED blinking when it reads the ADC input.

    When I run it, if I comment the function ADCConfigure(), it just blinks normally because I'm not initializing the ADC input. But when I uncomment, it can't build the program giving these four errors:

    #10010 errors encountered during linking; "Teste20Fev.out" not built
    #10234- unresolved symbols remain
    unresolved symbol TSCADCModuleClkConfig, first referenced in ./Teste20Fev.obj
    unresolved symbol TSCADCPinMuxSetUp, first referenced in ./Teste20Fev.obj

    As you referred above is related with the function TSCADCModuleClkConfig, so if you could help me I would very grateful. If you need I can post the algorithm.

    Best regards,
    Luciano.
  • Hi Anant Pai,

    I don't want to be boring, but can you answer to my lastest question? I would be very grateful if you could help me on this matter. Thanks in advance.

    Best regards,
    Luciano.
  • Hi Luciano,

    Currently there is no ADC application for beagleboneblack so the platform related functions like Pinmux and ModuleClock are missing for this board. So copying the tscAdc file defined for evmskAM335x to platform/beaglebone/ folder is essential.

    If you add new platform functions then you need to update their decalarations in the header file of the respective board like for beaglebone file is include/armv7a/am335x/beaglebone.h

    If you are using CCS to build your program then in addition to copying the file you have to add the tscAdc.c file to platform CCS project to include it in the build.

    Please refer Linking/Adding Source Files to Project in this link http://processors.wiki.ti.com/index.php/StarterWare_Project_Creation for info on adding/removing files to a project.

    For GCC toolchain you may have to update the makefile of platform to include the newly added file in the build. This step is needed only if the newly added file is not included in the build.

    The above steps should resolve the linking errors you are facing.

    The DAL file tsc_adc.c is common across all boards of AM335x you can use the APIs without any issues.

    Most of the examples have some common dependencies like system_config, platform, drivers. utils first ensure these dependencies are building cleanly for the board you are trying to build an application.

    In addition to these dependencies based on some usecases some more dependencies like nandlib, third_party etc maybe required which you have to take care while building the application.

    Hope this helps you make progress.

    Regards

    Anant Pai

  • Hey Anant Pai,

    Thank you so much! It is working. I can read the analog inputs. Now I will do some tests to see its potential.

    Best Regards,
    Luciano.
  • Hey Anant Pai,

    I have tested all ADC ports and I could read them all. The thing is, if I fix a tension (between 0 and 1.8V), like for example 0V, the AIN values continue to vary from 0 to 4095, independently of the input value, instead of being zero or near that. I am using the ADC EVM example as base.

    This is the main for only 2 analog inputs. I did a while loop to constantly read the ADC. The others functions stayed the same.

    int main(void)
    {
                 SetupIntc();

                 ADCConfigure();

                 while(1)

         {

    /* Read data from fifo 0 */
    sample1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* Read data from fif 1*/
    sample2 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);

    val1 = (sample1 * RESOL_X_MILLION) / 1000;

    val2 = (sample2 * RESOL_X_MILLION) / 1000;

         }

    }

    Did this situation already happen? I don't know if this information is enough to evaluate the problem. If you need more, just say it. Thanks for the attention. 

    Best regards,

    Luciano.

  • Hey,

    I have already discovered how to read the ADC channels from AIN0 to AIN6 in a while loop.

    The way I did it is working, but if someone realizes that this is not the correct way to do it, please correct me.

    The algorithm is based on the EVM ADC example and there are some details in the code that I changed:

    1. Reconfigure the function ADCConfigure():

           - Changed the TSCADCConfigureAFEClock to 24 MHz to get the maximum (not fundamental to see it working);
           - If you want use all the inputs (AIN0 - AIN6), you have got to configure the steps you need:

              StepConfigure(0, TSCADC_FIFO_0, TSCADC_POSITIVE_INP_CHANNEL1);
                  ...
                  to
                  ...
              StepConfigure(6, TSCADC_FIFO_0, TSCADC_POSITIVE_INP_CHANNEL7);

           - The same about StepEnable (I only use these functions inside the while loop once I only need there as you will see further. If I use them inside ADCConfigure and in the while loop too they will not be correctly corresponded):

              TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 1, 1);
               ...
               to
               ...
             TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 7, 1);

          - Once I'm not using interruptions, I dont need the following functions, so I commented:

             CleanUpInterrupts();
             TSCADCEventInterruptEnable(SOC_ADC_TSC_0_REGS, TSCADC_END_OF_SEQUENCE_INT);

    2. Main()

         - Don't need the function SetupIntc() as well as ADCIsr(), once not using interruptions!

         - Don't need also ConsoleUtilsInit() and ConsoleUtilsSetType(CONSOLE_UART):
                - I watch the inputs varying adding the variables to expressions!

         - Don't forget to declare the variables sample0 to sample6.

         - You can also use TSCADC_FIFO_1 instead of TSCADC_FIFO_0, or them together.

         - So the main will stay something like this:



    int main(void)
    {


    ADCConfigure();

    while(1)
    {

    /* Enable step 1 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 1, 1);

    /* Enable step 2 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 2, 1);

    /* Enable step 3 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 3, 1);

    /* Enable step 4 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 4, 1);

    /* Enable step 5 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 5, 1);

    /* Enable step 6 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 6, 1);

    /* Enable step 7 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 7, 1);


    /* AIN0 */
    sample0 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* AIN1 */

    sample1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);


    /* AIN2 */

    sample2 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* AIN3 */

    sample3 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* AIN4 */

    sample4 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* AIN5 */

    sample5 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    /* AIN6 */

    sample6 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

    }

    }

    Now after you run it, if you want the inputs varying you must do something important:

    After entering in debug mode, in pause mode, you add a breakpoint in the position of the while loop and then go the breakpoint properties, and where it says:

    - Debugger Response
          - Action: choose Update view instead of remain halted.

    - I hope this helps you all to use de Analog Inputs.

    Took me a few time, but remember, impossible is nothing!

    If someone have any doubts, just say it and I'll try my best to explain it.

    Best Regards,
    Luciano.