sam l21 xplained pro qt btn1 tutorial

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, 

where can i find QT BTN1 ASF example for saml21 xplained pro board. ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would also really, really love any example code or tutorial information on the QTouch button for the SAML21 Xplained Pro board. I'm really struggling to make any of the other examples for the SAML21 or SAMD21 work ...

 

Thanks for any help!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

According to the SAML21 xplained Pro User guide, the Onboard QTouch button 1 is connected to PA10 which is AIN[18]. I would try to install the "Quick Start for SAM ADC Driver (Call back) and change the ADC positive input to ADC_POSITIVE_INPUT_PIN18.

 

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello PhillyNJ,

Thank you so much for the tip!!

I believe I have got the idea. Just to be clear (for my own records and any newbies that might find this), it sounds liek you are saying:
(1) Create a new solution and project based on the "Quick Start for the SAM ADC Driver (Callback) - SAM L21 Xplained Pro (ATSAML21J18B)" (I did this by installing QTouch Composer and QTouch libraries, then going through the QTouch Start Page after clearing the "Touch" text from the search box. There is probably a more straightforward way)
(2) modify qs_adc_callback.c to set config_adc.positive_input to ADC_POSITIVE_INPUT_PIN18.
(3) everything compiles and programs successfully.
(4) presumably put code into the adc_complete_callback to do something useful on a successful read.

This is my first time working with an Atmel product. In my flailing around for QTouch examples, most of them seem to leverage the sleep mode and QTouch library / QTouch Composer, which I think provides tools for tuning the parameters of the sensor (sensitivity, etc.) They mostly seemed to rely on being built from the QTouch Start page (which makes a whole bunch of configuration files like touch.h, etc.) and produce starter code something like below:

I guess my question is whether this approach is going to take advantage of the cool features of the QTouch button (e.g. waking from sleep on touch, etc.)?

Other example code.

AND THANK YOU SO MUCH!!

​int main(void)
{
    /**
     * Initialize and configure system and generic clocks.
     * Use conf_clocks.h to configure system and generic clocks.
     * This example project uses Internal 8MHz oscillator.
     * The PTC module clock is provided using GCLK generator 1.
     */
    system_init();

    /**
     * Initialize delay service.
     */
    delay_init();

    /**
     * Initialize timer.
     * This example projects uses RTC timer for providing timing
     * info to QTouch library.
     */
    timer_init();
    
   /**
    * Configure VREG OF SUPC
    */
    configure_Vreg_Supc();
    
    /**
    * Configure system performance level
    */
    configure_performance_level();

    /**
     * Initialize QTouch library and configure touch sensors.
     */
    touch_sensors_init();

    /* Configure System Sleep mode to STANDBY MODE. */

    system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);

    while (1) {
        /**
         * Goto STANDBY sleep mode, unless woken by timer or PTC
         *interrupt.
         */
        system_sleep();

        /**
         * Start touch sensor measurement, if
         *touch_time.time_to_measure_touch flag is set by timer.
         */
        touch_sensors_measure();

        /**
         * Update touch status once measurement complete flag is set.
         */

        /**
         * Self Cap method
         */
        
        if ((p_selfcap_measure_data->measurement_done_touch == 1u)) {
            uint8_t sensor_state = GET_SELFCAP_SENSOR_STATE(0);
        }

    }

}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ccountryman wrote:
(2) modify qs_adc_callback.c to set config_adc.positive_input to ADC_POSITIVE_INPUT_PIN18.

Thats what I meant. In the example ADC project with the input changed to AIN[18], are you getting a reading?

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi PhillyNJ,

I'm actually really struggling with how to read the ADC. To figure out the ADC value and display it this is taking me into analog to digital conversion result buffers, using the UART ... all interesting stuff, but all I really want to do hang out in low-power mode and use the QTouch button to wake and toggle an output pin. This sounds like the perfect application for the SAML21, which sleeps at super low power and can wake from touch, and a perfect fit for this board, which has a touch button built in! I naively thought that there would be some sample code that would basically do just that. Treating the QTouch button as an ADC input is cool, but feels like maybe not the right way to structure this because I am not using any of the native touch functionality (including the tuning features to adjust button sensitivity, etc.) and I'm not using the sleep mode (which is part of the touch examples which *don't* use the on-board touch button of the SAML21 Xplained Pro board. Kinda feels like I am reinventing the wheel, right? I am really new to this, so I'm sorry if I am not making any sense.

I am really grateful for your help but worried that this approach won't take  me to my goal. Atmel has an example for this board PLUS the QT3 add-on, so I ordered that, but it's a much more complicated implementation with sliders and such. Still really wishing Atmel had a QTouch example for this board ...

I will keep trying to get a reading out of the ADC... thanks again!

Chris

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, So I picked up a SAML21 xplained pro. I figured, the QT button was connect to the ADC pin. I was wrong. As you mentioned, you need to install the Qtouch libraries. I am still digging through the 1 example which is so convoluted, I cant image why they dont add a simple example or provide better documentation.

 

From what I can tell the button is either SPI or i2c...

 

Still researching

"When all else fails, read the directions"