搜索
bottom↓
回复: 15

新手qtouch问题

[复制链接]

出0入0汤圆

发表于 2011-8-23 11:31:34 | 显示全部楼层 |阅读模式
#define _QTOUCH_
#define QT_NUM_CHANNELS 4
#define QT_MAX_NUM_ROTORS_SLIDERS 0
#define _SNS_SNSK_SAME_PORT_  
#define SNSK A
#define SNS A
#define QT_DELAY_CYCLES 10

#include"avr\io.h"
#include"avr\interrupt.h"
#include"touch_api.h"

volatile unsigned int hw_time_ms;

SIGNAL(SIG_OVERFLOW1)
{
        TCNT1H=0xFF;
        TCNT1L=0x83;
        hw_time_ms++;
}

void port_init(void)
{
        SFIOR|=(1<<PUD);
        DDRB=0xFF;
        PORTB=0xFF;
        DDRC=0xFF;
        PORTC=0xFF;
        DDRD=0xFF;
        PORTD=0xFF;
}

void timer1_init(void)
{
        TCNT1H=0xFF;
        TCNT1L=0x83;
        TCCR1B|=(1<<CS11)|(1<<CS10);
}

void int_ctrl(void)
{
        sei();
        TIMSK|=(1<<TOIE1);
}

void sys_init(void)
{
        port_init();
        timer1_init();
        int_ctrl();
        hw_time_ms=0;
}

int main(void)
{
        sys_init();
        qt_enable_key(CHANNEL_1, NO_AKS_GROUP, RECAL_12_5, HYST_25);//A
        qt_init_sensing();
        while(1)
        {
                qt_measure_sensors(hw_time_ms);

                if(qt_measure_data.qt_touch_status.sensor_states[0]&0x01)
                        PORTC&=~(1<<PC0);//A灯亮
                else
                        PORTC|=(1<<PC0);//A灯灭
        }
}


qt_init_sensing();为什么编译出错啊

burst_0_1_00_0_0.c:(.text+0x28): undefined reference to `_0111010111_'
burst_0_1_00_0_0.c:(.text+0x56): undefined reference to `_01001010111_'
burst_0_1_00_0_0.c:(.text+0xfa): undefined reference to `_0101110111_'
make: *** [qtouch_ex.elf] Error 1


好像qtouch没完全搞明白啊
请求技术援助,所用库libavr5g1-4qt-k-0ros.a

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出0入296汤圆

发表于 2011-8-23 13:10:32 | 显示全部楼层
官方用户手册下载了么?
官方用户手册有一步一步来的设置介绍。感觉你是没有正确配置阿。

出0入0汤圆

发表于 2011-10-1 15:35:23 | 显示全部楼层
回复【1楼】Gorgon Meducer  傻孩子
-----------------------------------------------------------------------
Build started 1.10.2011 at 15:31:01
avr-gcc -I"D:\Users\mhlyjay\Desktop\LPC2368-Touch MP4.B3\prog\test\..\..\..\..\..\..\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\AVR_Tiny_Mega_XMega\QTouch\common_files" -I"D:\Users\mhlyjay\Desktop\LPC2368-Touch MP4.B3\prog\test
\..\..\common_files" -I"D:\Users\mhlyjay\Desktop\LPC2368-Touch MP4.B3\prog\test\..\..\..\..\..\..\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\include"  -mmcu=atmega88 -Wall -gdwarf-2 -std=gnu99 -D_ROTOR_SLIDER_ -DQT_NUM_CHANNELS
=8  -DSNSK1=B  -DSNS1=D  -DQT_DELAY_CYCLES=1  -D_DEBUG_INTERFACE_  -D_QTOUCH_    -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main_atmega88.o -MF dep/main_atmega88.o.d  -c  ../main_atmega88.c

avr-gcc -mmcu=atmega88 -Wl,-Map=2080A_example.map main_atmega88.o   -L"D:\Users\mhlyjay\Desktop\LPC2368-Touch MP4.B3\prog\test\..\..\library_files" -L"D:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\AVR_Tiny_Mega_XMega\QTouch\lib
rary_files"  -lavr4g1-8qt-k-2rs  -o 2080A_example.elf

D:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\AVR_Tiny_Mega_XMega\QTouch\library_files\libavr4g1-8qt-k-2rs.a(burst_0_1_00_0_0.o): In function `burst_0_1_00_0_0':
burst_0_1_00_0_0.c:(.text+0x2a): undefined reference to `_0111010111_'
burst_0_1_00_0_0.c:(.text+0x54): undefined reference to `_01001010111_'
burst_0_1_00_0_0.c:(.text+0xf0): undefined reference to `_0101110111_'
make: *** [2080A_example.elf] Error 1
Build failed with 3 errors and 0 warnings...




我也出现同样的问题啊,紧急求解
用的AVR Studio4,winAVR-20100110,Qtouch library4.4.

出0入0汤圆

发表于 2012-5-5 21:11:47 | 显示全部楼层
Gorgon_Meducer 发表于 2011-8-23 13:10
官方用户手册下载了么?
官方用户手册有一步一步来的设置介绍。感觉你是没有正确配置阿。 ...

能不能教教我,AVR和Qtouch,点亮一个灯的程序,我用的是ATmega16A
初学者,见谅

出0入296汤圆

发表于 2012-5-6 22:43:48 | 显示全部楼层
mhlyjay 发表于 2011-10-1 15:35
回复【1楼】Gorgon Meducer  傻孩子
------------------------------------------------------------------ ...

好像是工程里面没有加入对应的.a文件……

出0入296汤圆

发表于 2012-5-6 22:46:00 | 显示全部楼层
wgco 发表于 2012-5-5 21:11
能不能教教我,AVR和Qtouch,点亮一个灯的程序,我用的是ATmega16A
初学者,见谅 ...

虽然很想帮你,但我这里没有硬件,精力上也不太允许。
我的建议还是你先看完官方提供的手册。我记得手册里面有非常相近的手把手图文教程。

另外,如果你能提出一些很具体的问题——相对这个笼统的请求来说——论坛上会有大把的热心人帮你进行解答。

出0入0汤圆

发表于 2012-5-6 23:13:10 | 显示全部楼层
很明显,是头文件没有包含进来。

出0入0汤圆

发表于 2012-5-7 10:53:20 | 显示全部楼层

#include <avr/io.h>
#include <avr/interrupt.h>
#define __delay_cycles(10)     __builtin_avr_delay_cycles(10)
#define __enable_interrupt()  sei()

/*  now include touch api.h with the localization defined above */
#include "touch_api.h"

/*----------------------------------------------------------------------------
                            manifest constants
----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------
                            type definitions
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
                                prototypes
----------------------------------------------------------------------------*/

/*  initialise host app, pins, watchdog, etc    */
static void init_system( void );
/*  configure timer ISR to fire regularly   */
static void init_timer_isr( void );
/*  Assign the parameters values to global configuration parameter structure    */
static void qt_set_parameters( void );
/*  Configure the sensors */
static void config_sensors(void);

/*  Configure the sensors for  Keys configuration */
    static void config_keys(void);





/*----------------------------------------------------------------------------
                            Structure Declarations
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
                                    macros
----------------------------------------------------------------------------*/


#define GET_SENSOR_STATE(SENSOR_NUMBER) qt_measure_data.qt_touch_status.sensor_states[(SENSOR_NUMBER/8)] & (1 << (SENSOR_NUMBER % 8))
#define GET_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER) qt_measure_data.qt_touch_status.rotor_slider_values[ROTOR_SLIDER_NUMBER]

/*----------------------------------------------------------------------------
                                global variables
----------------------------------------------------------------------------*/
/* Timer period in msec. */
uint16_t qt_measurement_period_msec = 25u;

/*----------------------------------------------------------------------------
                                extern variables
----------------------------------------------------------------------------*/
/* This configuration data structure parameters if needs to be changed will be
   changed in the qt_set_parameters function */
extern qt_touch_lib_config_data_t qt_config_data;
/* touch output - measurement data */
extern qt_touch_lib_measure_data_t qt_measure_data;
/* Get sensor delta values */
extern int16_t qt_get_sensor_delta( uint8_t sensor);



/*----------------------------------------------------------------------------
                                static variables
----------------------------------------------------------------------------*/

/* flag set by timer ISR when it's time to measure touch */
static volatile uint8_t time_to_measure_touch = 0u;

/* current time, set by timer ISR */
static volatile uint16_t current_time_ms_touch = 0u;

/*============================================================================
Name    :   main
------------------------------------------------------------------------------
Purpose :   main code entry point
Input   :   n/a
Output  :   n/a
Notes   :
============================================================================*/

int main( void )
{
    /*status flags to indicate the re-burst for library*/
    uint16_t status_flag = 0u;
    uint16_t burst_flag = 0u;

/* initialise host app, pins, watchdog, etc */
    init_system();

    /* Configure the Sensors as keys or Keys With Rotor/Sliders in this function */
    config_sensors();

    /* initialise touch sensing */
    qt_init_sensing();

    /*  Set the parameters like recalibration threshold, Max_On_Duration etc in this function by the user */
    qt_set_parameters( );

    /* configure timer ISR to fire regularly */
    init_timer_isr();


    /*  Address to pass address of user functions   */
    /*  This function is called after the library has made capacitive measurements,
    *   but before it has processed them. The user can use this hook to apply filter
    *   functions to the measured signal values.(Possibly to fix sensor layout faults)    */
    qt_filter_callback = 0;



    /* enable interrupts */
    __enable_interrupt();

// /* loop forever */
//    for( ; ; )
//   {
//        if( time_to_measure_touch )
//        {

            /*  clear flag: it's time to measure touch  */
//            time_to_measure_touch = 0u;

//            do {
                /*  one time measure touch sensors    */
//                status_flag = qt_measure_sensors( current_time_ms_touch );
               
//               burst_flag = status_flag & QTLIB_BURST_AGAIN;

  /* Time-critical host application code goes here */

//                   }while (burst_flag) ;
            


  /*  Time Non-critical host application code goes here  */
//               }
//        }


         while(1)
         {
               if( time_to_measure_touch )
                                   {
                                    time_to_measure_touch = 0u;

                                        qt_measure_sensors( current_time_ms_touch) ;
                                 }       

                if(qt_measure_data.qt_touch_status.sensor_states[0]&0x01)
                         PORTC&=~(1<<PC0);//A灯亮
                 else
                         PORTC|=(1<<PC0);//A灯灭
         }




}




/*============================================================================
Name    :   config_sensors
------------------------------------------------------------------------------
Purpose :   Configure the sensors
Input   :   n/a
Output  :   n/a
Notes   :   n/a
============================================================================*/
static void config_sensors(void)
{
       
        config_keys();

}
/*============================================================================
Name    :   config_keys
------------------------------------------------------------------------------
Purpose :   Configure the sensors as keys only
Input   :   n/a
Output  :   n/a
Notes   :   n/a
============================================================================*/



static void config_keys(void)
{
    /*  enable sensors 0..3: keys on channels 0..3  */
    qt_enable_key( CHANNEL_0, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_1, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_2, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_3, AKS_GROUP_1, 10u, HYST_6_25 );
    /*  enable sensors 4..7: keys on channels 4..7   */
    qt_enable_key( CHANNEL_4, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_5, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_6, AKS_GROUP_1, 10u, HYST_6_25 );
    qt_enable_key( CHANNEL_7, AKS_GROUP_1, 10u, HYST_6_25 );


}




/*============================================================================
Name    :   init_system
------------------------------------------------------------------------------
Purpose :   initialise host app, pins, watchdog, etc
Input   :   n/a
Output  :   n/a
Notes   :
============================================================================*/

static void init_system( void )
{
    /*  disable pull-ups    */
    MCUCR |= (1u << PUD);

}

/*============================================================================
Name    :   timer_isr
------------------------------------------------------------------------------
Purpose :   timer 1 compare ISR
Input   :   n/a
Output  :   n/a
Notes   :
============================================================================*/

ISR(TIMER1_COMPA_vect)
{
    /*  set flag: it's time to measure touch    */
    time_to_measure_touch = 1u;

    /*  update the current time */
    current_time_ms_touch += qt_measurement_period_msec;
}


/*============================================================================
Name    :   qt_set_parameters
------------------------------------------------------------------------------
Purpose :   This will fill the default threshold values in the configuration
            data structure.But User can change the values of these parameters .
Input   :   n/a
Output  :   n/a
Notes   :   initialize configuration data for processing
============================================================================*/

static void qt_set_parameters( void )
{
    /*  This will be modified by the user to different values   */
    qt_config_data.qt_di              = DEF_QT_DI;
    qt_config_data.qt_neg_drift_rate  = DEF_QT_NEG_DRIFT_RATE;
    qt_config_data.qt_pos_drift_rate  = DEF_QT_POS_DRIFT_RATE;
    qt_config_data.qt_max_on_duration = DEF_QT_MAX_ON_DURATION;
    qt_config_data.qt_drift_hold_time = DEF_QT_DRIFT_HOLD_TIME;
    qt_config_data.qt_recal_threshold = DEF_QT_RECAL_THRESHOLD;
    qt_config_data.qt_pos_recal_delay = DEF_QT_POS_RECAL_DELAY;
}
编译之后是:
Build started 7.5.2012 at 10:50:08
avr-gcc -I"C:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\include" -I"C:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\debug" -I"C:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Librarie
s\AVR_Tiny_Mega_XMega\QTouch\common_files" -I"C:\Program Files\Atmel\Atmel_QTouch_Libraries_4.4\Generic_QTouch_Libraries\AVR_Tiny_Mega_XMega\QTouch\library_files"  -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 -DQT_DELAY_CYCLES=1 -D_QTOUCH_ -DSNSK1=A -DQT_NUM_
CHANNELS=8 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  -DSNS1=A -Wp,-M,-MP,-MT,11111.o,-MF,dep/11111.o.d  -c   ../11111.c -o 11111.o

../11111.c:45:24: "10" may not appear in macro parameter list
../11111.c: In function `main':
../11111.c:133: warning: unused variable `status_flag'
../11111.c:134: warning: unused variable `burst_flag'
../11111.c: At top level:
../11111.c:282: warning: return type defaults to `int'
../11111.c: In function `ISR':
../11111.c:282: warning: type of "TIMER1_COMPA_vect" defaults to "int"
../11111.c:288: warning: control reaches end of non-void function
../11111.c: At top level:
../11111.c:67: warning: 'init_timer_isr' used but never defined
make: *** [11111.o] Error 1
Build failed with 1 errors and 6 warnings...
不知道哪儿错了,怎么改?

出0入0汤圆

发表于 2012-5-7 11:14:33 | 显示全部楼层
你这是那个.a库文件没有包含进来,需要去Project Options选项里面的Libraries里面设定库的路径,选择对应的的库,根据你做几按键几WHEEL_ROTOR来定。

出0入0汤圆

发表于 2012-5-7 11:18:18 | 显示全部楼层
本帖最后由 wzyllgx 于 2012-5-7 11:21 编辑

新手建议看一下Atmel QTouch Library User Guide,包括里面的条件编译都有说明。因为这个TOUCH不是你COPY一个代码过来就可以编译过的,里面要设定的条件太多,需要一项项来设定,对不同系列的芯片有不同的的TOUCH API和TOUCH CONFIG。

出0入0汤圆

发表于 2012-5-15 18:05:29 | 显示全部楼层
wzyllgx 发表于 2012-5-7 11:18
新手建议看一下Atmel QTouch Library User Guide,包括里面的条件编译都有说明。因为这个TOUCH不是你COPY一 ...

Atmel QTouch Library User Guide这个在哪下啊?

大侠能否告诉在哪能找到qtouch原理方面的资料呢?

您有什么好的文档,能不能传上来看看呢?

出0入0汤圆

发表于 2012-5-15 19:01:25 | 显示全部楼层
www.atmel.com    这里有你需要的资料。

出0入0汤圆

发表于 2012-5-16 16:47:49 | 显示全部楼层
wzyllgx 发表于 2012-5-15 19:01
www.atmel.com    这里有你需要的资料。

Qtouch的library说明我倒是找到了,但是讲起原理的文档俺没有找打,大侠给个具体连接呗,

最好还有Qmatrix的原理;

出0入0汤圆

发表于 2012-5-16 17:05:19 | 显示全部楼层
jade1988 发表于 2012-5-16 16:47
Qtouch的library说明我倒是找到了,但是讲起原理的文档俺没有找打,大侠给个具体连接呗,

最好还有Qmatr ...

http://www.atmel.com/Images/doc8207.pdf
另外这里可能还有你感兴趣的资料:http://www.atmel.com/products/To ... .aspx?tab=documents

出0入0汤圆

发表于 2012-5-16 17:22:56 | 显示全部楼层
wzyllgx 发表于 2012-5-16 17:05
http://www.atmel.com/Images/doc8207.pdf
另外这里可能还有你感兴趣的资料:http://www.atmel.com/produ ...

谢谢了,哈哈;

出0入0汤圆

发表于 2012-7-30 11:18:51 | 显示全部楼层
当时出现楼主出现的问题时,没有看到楼主的帖子。

后来按照坛里的说明调试后,也没法解决。

最后发现是qt_asm_tiny_mega.s这个文件没有和其他源程序放在一个文件夹下面。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 22:32

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表