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.

ADC conf registers on AM335x



I'm writing bare-metal code on Sitara AM335x (Beaglebone Black) and would like to know what is the minimum setup/configuration that is needed to access the Touch-Screen/ADC info? Because I am operating without Linux or Windows I need to understand what registers need to be set before I can sample "user-input".

Sincerely,
Dean

  • Hi Dean,

    Try downloading the AM335X Starterware package. It has ADC examples in an OS-less environment, that you can use as a reference for writing your own code.

  • Biser:

    Thanks for your suggestion. I have the Starterware code and have taken the "touch-driver" files from the "DEMO" project and trying to use them. I encounter this problem: when I call "TouchInit()" function (located in "demoTouch.c" the processor locks-up (ie no more UART / serial output) at the following:

    /* configures ADC to 3Mhz */
    TSCADCConfigureAFEClock(SOC_ADC_TSC_0_REGS, 24000000, 3000000);

    Is there something else that needs to be setup or configured BEFORE calling "TouchInit()"?

    I doubt that this is relevant but I am already driving the UART/serial output (for debug purposes) and successfully driving the LCD output channel (for a display). Now I need to add the "touch-screen" capability to my project.

    Sincerely,

    Dean Wedel

  • Hi Dean,
     
    Sorry, I'm not a software expert. Starterware is supported on this forum: http://e2e.ti.com/support/embedded/starterware/default.aspx
  • Dean,

    Most likely the problem here is that you have not initialized the PLL for the ADC. As a result, when you call the function TSCADCConfigureAFEClock(), you will see an error in CCS because it's trying to access registers for a peripheral whose clocks have not been initialized. 

    Look in the tscAdc.c file for a function called TSCADCModuleClkConfig(). This will initialize the PLL for the TSCADC module and afterwards you should be able to access the peripheral registers.

    -Tyler

  • Tyler:

    Thanks for your help! I've added a call to the function TSCADCModuleClkConfig() and added the tscAdc.c file to my project. This allowed the "TouchInit()" to run quite abit further before freezing up.

     

    Now in TouchInit() it locks at the call to:

    DMTimerModeConfigure(SOC_DMTIMER_3_REGS, DMTIMER_ONESHOT_CMP_ENABLE);

     

    I must be missing something else that needs to be configured??

     

    Thanks again!

    Dean

  • Dean,

    You're probably running into the same problem here. You need to make sure the clocks are configured for the DM Timer before calling that function. 

    -Tyler

  • Thanks again for you input. I'll check on the timers.

    However, isn't there a way to sample the actual TouchScreen/ADC data inputs rather than having to configure interrupts/timers? What if I do not want my main software loop interrupted by an unneeded user "touch" before I'm ready for it?

    Dean

  • Dean,

    What exactly are you trying to do? Are you using just a touchscreen or a touchscreen plus some generic ADC input?

    -Tyler

  • Tyler:

    I am only trying to use "TouchScreen" ~ I'm not using the ADC for any sort of "generic" sensor readings. However, I do wish to only poll for TouchScreen sample-data when my system is not doing time-critical functions.

    Thanks again,

    Dean

  • Dean,

    The way that demo code is written, it doesn't take any measurements until a touch has been detected. Furthermore, the touch panel is mechanical and will bounce like a switch when pressed. The DM timer is used in this example as a debounce mechanism as to not trigger any false detections while the bouncing occurs.

    You can do a couple things to prevent the touchscreen from interfering with your time-critical functions:

    The first is to disable the TSC/ADC module by resetting bit 0, the Enable bit, in the CTRL register. This will turn off the entire module but you're configuration will not be lost. Once your time-critical code has completed you can simply turn the module back on to continue using the touch screen.

    The second option is to clear the STEPENABLE register. This will disable the steps that get executed when a touch occurs. Since there are no steps to schedule when a touch occurs, the state machine will stay in the Idle step and do nothing.

    In either case, you should make sure the module isn't in the middle of a conversion by checking the ADCSTAT register. The FSM_BUSY field will tell you if the AFE is busy performing a conversion. Furthermore, the STEP_ID field will tell you which step the state machine is currently executing. You want both of these to report Idle before either turning off the module or clearing the STEPENABLE register.

    Regards,

    Tyler

  • Tyler:

    Based on your knowledge and description it sounds like Option-#1 above is what I need at this point.


    From the "Demo" project I see a LOT of items being started before the call to "TouchInit()" which I don't care about such as "ToneLoopInit()" and "AudioCodecInit()" and "Raster0Init()" (ie I'm already handling the video). 

    However, in order for the Touch input to work (the DM Timer that failed above) do I need the following to run??

    Timer2IntRegister();
    Timer4IntRegister();

    Thanks again for your expert experience.

    Sincerely,

    Dean Wedel

  • Dean,

    The DM Timer is not required for touchscreen functionality. That code example includes it as a debounce mechanism for the purpose of demonstration. The more features that get exercised in the demo, the more references end users have available to work with.

    -Tyler

  • Tyler:

    Ok on the timers. That brings me to the question of what is the bare-minimum that I need to "initialize" for the touch-screen to provide sampling? 

    Sincerely,

    Dean

  • Dean,

    At a minimum you need the instructions in the TouchInit() function you've referred to with the DM Timer instructions removed and at least 2 steps configured. Currently that init function configures 10 steps, 5 for each axis (X & Y). You could get away with only 2 steps, one for the X-axis and one for the Y-axis.

    -Tyler

  • Tyler,

    I have that code successfully building and running on my Black now. However, I'm not getting any response from touch at all. I also tried adding a call to function "TSCADCPinMuxSetUp()" after looking around in the "Demo" some more ~ but it didn't help at all that I can tell.

    Maybe I should try a different approach: Is there a way that the Touchscreen(ADC)-input could be re-configured to a DMA block that I could scan?? I'm simply thinking down the line of how I'm using the LCD for output with a memory-block that I shove raster-data into. . .

    Thanks again,

    Dean

  • Dean, 

    Is the code ever getting to the Touchscreen ISR? If everything is configured properly you should be getting a FIFO threshold interrupt once there are 5 words in the FIFO (according to the demo code).

    If you're not ever seeing that interrupt I would try enabling the HW Pen Event interrupt to make sure you're actually getting a successful touch detection. 

    -Tyler

  • Tyler:

    That was a good suggestion ~ I tried using TSCADC_ASYNC_HW_PEN_EVENT_INT, TSCADC_SYNC_PEN_EVENT_INT, and TSCADC_PEN_UP_EVENT_INT individually instead of the TSCADC_FIFO1_THRESHOLD_INT that the "Demo" code uses. Not ANY events at all.

    I'm not sure what that tells us except maybe the ADC isn't configured correctly ??

    Dean

  • Dean,

    Can you share you register configuration for the CTRL and IDLECONFIG registers?

    -Tyler

  • Tyler:

    The code reads like this:

    CTRL:
    Inside of "TouchInit()" the call is:
    TSCADCHWEventMapSet(SOC_ADC_TSC_0_REGS, TSCADC_PEN_TOUCH);
    The function is as follows:
    void TSCADCHWEventMapSet(unsigned int baseAdd, unsigned int hwEvent)

    {

    HWREG(baseAdd + TSC_ADC_SS_CTRL) &= ~TSC_ADC_SS_CTRL_HW_EVENT_MAPPING;

    HWREG(baseAdd + TSC_ADC_SS_CTRL) |= hwEvent <<

    TSC_ADC_SS_CTRL_HW_EVENT_MAPPING_SHIFT;

    }

    =================================================================================
    IDLECONFIG:
    Inside of "TouchInit()" the call is:
    TSCADCIdleStepOperationModeControl(SOC_ADC_TSC_0_REGS, TSCADC_SINGLE_ENDED_OPER_MODE);

    The function is as follows:
    void TSCADCIdleStepOperationModeControl(unsigned int baseAdd, unsigned int mode)

    {

    if(mode)

    {

    HWREG(baseAdd + TSC_ADC_SS_IDLECONFIG) |=

    TSC_ADC_SS_IDLECONFIG_DIFF_CNTRL;

    }

    else

    {

    HWREG(baseAdd + TSC_ADC_SS_IDLECONFIG) &=

    ~TSC_ADC_SS_IDLECONFIG_DIFF_CNTRL;

    }

    }

    Dean

  • Dean,

    You may be missing a couple of important function calls that setup the bias transistors for the Idle step. Without these properly configured you won't ever get touch detections. I'm referring to functions:

    TSCADCIdleStepConfig();

    TSCADCIdleStepAnalogSupplyConfig();

    TSCADCIdleStepAnalogGroundConfig();

    Refer to the demo code for the necessary arguments for these functions.

    -Tyler

  • Tyler:

    The function you identified are included in my code "as-is" from the demo:

    /* Configure reference volatage and input to idlestep */

    TSCADCIdleStepConfig(SOC_ADC_TSC_0_REGS, TSCADC_NEGATIVE_REF_VSSA,

    TSCADC_POSITIVE_INP_CHANNEL1, TSCADC_NEGATIVE_INP_ADCREFM,

    TSCADC_POSITIVE_REF_VDDA);

    /* Configure the Analog Supply to Touch screen */

    TSCADCIdleStepAnalogSupplyConfig(SOC_ADC_TSC_0_REGS, TSCADC_XPPSW_PIN_OFF,

    TSCADC_XNPSW_PIN_OFF, TSCADC_YPPSW_PIN_OFF);

    /*

    **Configure the Analong Ground of Touch screen.
    */

    TSCADCIdleStepAnalogGroundConfig(SOC_ADC_TSC_0_REGS, TSCADC_XNNSW_PIN_OFF,

    TSCADC_YPNSW_PIN_ON, TSCADC_YNNSW_PIN_ON,

    TSCADC_WPNSW_PIN_OFF);

    Just a question, does the Touchscreen/ADC need any MUX setup?

    Sincerely,
    Dean

  • Dean,

    What is the value in the CTRL and IDLECONFIG registers while the ADC is running?

    The ADC inputs are dedicated analog inputs and therefore have no pin mux capabilities.

    -Tyler

  • Tyler:

    I have a loop running and this is the register values:

    CTRL = 0x000000c7
    IDLECONFIG = 0x00040500

    Dean

  • Dean,

    What kind of touch panel are you using? 4-wire/5-wire/8-wire?

    In your CTRL register settings, the AFE_Pen_Ctrl bits are configured for a 5-wire touch screen. For a 4-wire touch panel you need to set bit 5 only.

    Essentially what these bits do is enable an internal pull-up resistor on AIN0 or AIN4 depending on which bit you turn on (bit 5 for AIN0 and bit 6 for AIN4). A touch is detected when these pins get pulled low. For example, setting bit 5 of the CTRL register will enable a weak internal pull-up on AIN0 which we want for a 4-wire touch panel. In the IDLECONFIG register, you've got YPNSW and YNNSW transistors turned on which will act as a very strong pull-down on AIN2 and AIN3. When you touch the panel you're essentially shorting AIN0 to VSSA and a interrupt will be generated (if enabled). Therefore, if you're not seeing HW event interrupts then there's something wrong with your configuration.

    -Tyler

  • Tyler:

    There is the possibility that my "TouchScreen" isn't using the standard ADC channel at all,

    The screen I'm using is a Chipsee 7inch 5-wire capactive-touch http://www.chipsee.com/product/evm/beagle/beaglebone-black-expansion-capacitive.html .

    Here is more info: (touchscreen PDF schematic is attached2134.BBB-EXP-V1.pdf). On page #2 (right-hand-side) of this PDF it appears that the Capacitive-touch is being channeled as such:

    CAP_INT = GPIO1_17 (this I can see as an Interrupt flag when I touch the screen)

    I2C1_SCL = ?? I don't know how to MUX to test this data

    I2C1_SDA = ?? I don't know how to MUX to test this data

    Is there any "easy" code (in bare-metal-c)  that you could give me to sample these two data items for activity? Or am I simply confused?!?

    Thanks again for your understanding!

    Dean

  • Dean,

    It looks like Chipsee makes a resistive touch cape based on the same hardware which is why the schematic shows a connection for resistive touch. However, the link you provided is for the capacitive touch version of that cape so using the TSC_ADC_SS won't help you in this case. It also seems the capacitive touch controller on the display uses an I2C interface so I would recommend looking at starterware examples for I2C and the datasheet for the LCD in order to get your touch functionality working.

    -Tyler

  • Tyler:

    Thanks for all of the help you've given. I'm sorry for not realizing the "I2C" data channel earlier.

    Thanks again!

    Dean