Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Atmel QTouch Library Initialisation at run-time causing problem.

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hi All,
My query is related to Atmel QTouch Safety Library.
I am using SAMC20 micro-controller in one of my project, which has 10 selfcap touch sensors, all of them shall not be used, the sensors which needs to be used are defined in configuration which is received by SAMC20 from UART.
The basic idea is that, at power-up I am not initializing the sensors, first I wait for the configuration to be received from the UART and then I initialized only the configured sensors.
Everything was working fine, one day I send the configuration twice and then there comes the problem, the next time system receives the configuration, I started getting calibration error.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************//**
* @function  touch_sensors_init
* @brief  - Purpose: Example application entry function, for the PTC initialization
* @notes The function will test based on the periodicity set.
The periodicity is a multiple of the measurement time of the PTC set by the user
*//***************************************************************************/
touch_ret_t touch_sensors_init(void)
{
    touch_ret_t touch_ret = TOUCH_SUCCESS;
  fmea_error = 0;
  non_fmea_error = 0;
 
  touch_lib_di_data_block_t touch_lib_selfcap_di_data_block;
  touch_lib_di_data_block_t *p_selfcap_inv_dblk;
  touch_lib_selfcap_di_data_block.p_di_data_block = selfcap_inv_data_blk;
  p_selfcap_inv_dblk = &touch_lib_selfcap_di_data_block;
    /* Setup and enable generic clock source for PTC module. */
    touch_configure_ptc_clock();
 
    touch_time.measurement_period_ms = DEF_TOUCH_MEASUREMENT_PERIOD_MS;
    touch_userconfig.sync_measure_n_test = 0;
    touch_userconfig.fmea_time_count = SAFETY_FMEA_TIME_PERIOD_MSEC;
    touch_error_app_cb = touch_lib_error_callback;
    /* Initialize touch library for Self Cap operation. */
    touch_ret = touch_selfcap_sensors_init(&touch_config);
    sf_touchlib_status_di_check(touch_ret);
    if (touch_ret != TOUCH_SUCCESS) 
  {
        SAFETY_TOUCH_FAULT_ACTION(ERR_TCH_INIT, 0);
    }
 
    touch_ret = touch_selfcap_di_init(p_selfcap_inv_dblk);
    sf_touchlib_status_di_check(touch_ret);
 
    if (touch_ret != TOUCH_SUCCESS) 
  {
        SAFETY_TOUCH_FAULT_ACTION(ERR_TCH_DI_INIT, 0);
    }
 
#if DEF_TOUCH_QDEBUG_ENABLE == 1
    QDebug_Init();
#endif
 
    /* configure the touch library sensors. */
    touch_ret = touch_sensors_config();
    sf_touchlib_status_di_check(touch_ret);
    if (touch_ret != TOUCH_SUCCESS) 
  {
        SAFETY_TOUCH_FAULT_ACTION(ERR_TCH_SENSOR_CONFIG, 0);
    }
 
    /* Auto Tuning setting for calibration.
     *
     * AUTO_TUNE_PRSC: When Auto tuning of pre-scaler is selected
     * the PTC uses the user defined internal series resistor setting
     * (DEF_SELFCAP_SENSE_RESISTOR) and the pre-scaler is adjusted
     * to slow down the PTC operation to ensure full charge transfer.
     *
     * AUTO_TUNE_RSEL: When Auto tuning of the series resistor is
     * selected the PTC runs at user defined pre-scaler setting speed
     * (DEF_SELFCAP_CLK_PRESCALE) and the internal series resistor is
     * tuned automatically to the optimum value to allow for full
     * charge transfer.
     *
     * AUTO_TUNE_NONE: When manual tuning option is selected
     *(AUTO_TUNE_NONE),
     * the user defined values of PTC pre-scaler and series resistor is used
     * for PTC operation as given in DEF_SELFCAP_CLK_PRESCALE and
     * DEF_SELFCAP_SENSE_RESISTOR
     *
     */
    touch_ret = touch_selfcap_sensors_calibrate(0);
    sf_touchlib_status_di_check(touch_ret);
    if (touch_ret != TOUCH_SUCCESS) 
  {
    SAFETY_TOUCH_FAULT_ACTION(ERR_TCH_CALIB, 0);
    }
     /* Call data integrity function after every config_data change */
    touch_calc_selfcap_config_data_integrity();
 
#if (DEF_TOUCH_FMEA_TEST == 1)
     app_selfcap_fmea_init();
#endif
    return (touch_ret);
}



Whenever the above code is executed twice because configuration is received twice, the second time it throughs calibration error.
Can any one please help me, with this problem, I also found one function touch_xxxxcap_sensors_deinit, and calling this before the initialization function doesn't solves my problem.

Thanks in Advance.
 

Can you use a flag to check if calibrated or not calibrated and execute the function based on the flag value ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top