cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for example code TSL V.2.4.0 for STM8S105C6, STM8S103K3

hinnalear
Associate II
Posted on August 22, 2011 at 11:33

I try to modify code from TSL V.2.4.0 in ''Example01_STM8S207_RC_5k'' for run on STM8S103K3 and STM8S105C6.

Test on board STM8S discovery (for STM8S105C6).

Follow TSL document to modify code but it not work.

LED is blink (base code on project Adjustable LED blinking speed),

but on touch sense notting happen.

LED blink speed not change.

Both STM8S105C6T6 and STM8S103K3

I think, I try every thing in document say.

Can some one show me for the example code (for Cosmic compiler is great).

Thank for advance.

5 REPLIES 5
Max
ST Employee
Posted on August 22, 2011 at 12:09

Could you please describe better what is happening/not happening? what have you done to configure the TSL?

If your program is running, watch the variables sSCKeyInfo[key_number].state, sSCKeyInfo[key_number].Channel.LastMeasure and sSCKeyInfo[key_number].Reference using the STVD debugger (

http://www.st.com/internet/evalboard/product/210567.jsp

) or the STMStudio (

http://www.st.com/internet/evalboard/product/251373.jsp

) and describe what is happening.

In which state are the keys?

Is sSCKeyInfo[key_number].LastMeasure changing when you touch the keys?

hinnalear
Associate II
Posted on August 22, 2011 at 17:05

I recheck config on STM8S105C6.

My configuration some value wrong.

Now it's work done.

But on STM8S103K3 not work.

in debugging

sSCKeyInfo[key_number].state

  .whole = 8 '\b'

  .b all value is 0 only ERROR is 1.

sSCKeyInfo[key_number].Channel

  .LastMeasure = 0

  .Reference = 0

Then I try step run.

Set break point at TSL_Action();

When call TSL_Action(); about 3-4 time.

sSCKeyInfo[key_number].state.b.CALIBRATION set to 1.

After that ERROR is set to 1.

Value never change after ERROR set to 1. (with touch or not touch)

For STM8S103K3, I use STM8S discovery board by

remove STM8S105C6 and re wiring from STM8S103's pin to CN1, CN2, CN3 and CN4.

And connect pin like this

TL_Load is PE5

Point touch sence is PB0

LED is PC1

Not same as STM8S105C6 because it's easy to wire.

I guess this information may be usefull.

I not have oscilloscope but, I try volt meter at TS_Load.

On STM8S105C6 value is about 2 V.

but STM8S103K3 is 0 V.

Now, what can I do next ?

Some configuration

stm8s.h

/* Uncomment the line below according to the target STM8S or STM8A device used in your

   application. */

 /* #define STM8S208 */      /*!< STM8S High density devices with CAN */

 /* #define STM8S207 */      /*!< STM8S High density devices without CAN */

 /* #define STM8AF52Ax */    /*!< STM8A High density devices with CAN */

 /* #define STM8AF62Ax */    /*!< STM8A High density devices without CAN */

 /* #define STM8S105 */      /*!< STM8S Medium density devices */

 /* #define STM8AF626x */    /*!< STM8A Medium density devices */

#define STM8S103       /*!< STM8S Low density devices */

 /* #define STM8S903 */      /*!< STM8S Low density devices */

hinnalear
Associate II
Posted on August 22, 2011 at 17:11

stm8_tsl_conf.h

#define MCU_SELECTION  (4)

#define TIMACQ           (TIM2)

#define TIMACQ_CNTR_ADD  (0x530C)

#define TIMTICK         (TIM4)

#define LOADREF_PORT_ADDR  (GPIOE_BaseAddress)  /**< LOADREF pin GPIO base address */

#define LOADREF_BIT        (0x20)               /**< LOADREF pin mask */

#define SCKEY_P1_KEY_COUNT  (1)

#define SCKEY_P1_PORT_ADDR  (GPIOB_BaseAddress)  /**< Single channel key Port 1: GPIO base address */

#define SCKEY_P1_A  (0x01)  /**< Single channel key Port 1: 1st key mask */

#define SCKEY_P1_B  (0)  /**< Single channel key Port 1: 2nd key mask */

#define SCKEY_P1_C  (0)  /**< Single channel key Port 1: 3rd key mask */

#define SCKEY_P1_D  (0)  /**< Single channel key Port 1: 4th key mask */

#define SCKEY_P1_E  (0)     /**< Single channel key Port 1: 5th key mask */

#define SCKEY_P1_F  (0)     /**< Single channel key Port 1: 6th key mask */

#define SCKEY_P1_G  (0)     /**< Single channel key Port 1: 7th key mask */

#define SCKEY_P1_H  (0)     /**< Single channel key Port 1: 8th key mask */

#define SCKEY_P1_DRIVEN_SHIELD_MASK (0x00)

#define GPIOA_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOA */

#define GPIOB_ELECTRODES_MASK  (0x01)  /**< Electrodes mask for GPIOB */

#define GPIOC_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOC */

#define GPIOD_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOD */

#define GPIOE_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOE */

#define GPIOF_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOF */

#define GPIOG_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOG */

#define GPIOH_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOH */

#define GPIOI_ELECTRODES_MASK  (0x00)  /**< Electrodes mask for GPIOI */

Max
ST Employee
Posted on August 22, 2011 at 19:00

The most common cause of the keys going in error state is when the actual measure is out of the allowed range.

try changing the SCKEY_MIN_ACQUISITION  and SCKEY_MAX_ACQUISITIONdefinition in the configuration file

hinnalear
Associate II
Posted on August 24, 2011 at 06:33

I found my problem.

My touch sence button make circuit unstable.

When I remove my touch sence. It working properly. (Only STM8S103K3, not on STM8S105C6)

Your guide helpfull to debug problem.

Thank you very much.

0690X00000602mGQAQ.jpg