Application Description
- Question 1
How can the C/R-F functional block in the HT45R36 be implemented as a capacitive touch switch function?
- Question 2
If there are any unused channels among RC1-RC16, the how should they be managed?
- Question 3
When using the HT45R43/HT45R36 as a touch switch, are there any special considerations for the line from the RC pin to the touch switch?
- Question 4
When using the following instruction to read the contents of the TMRAH and TMRAL registers, the read back data contains errors.
mov A,TMRAL
mov a_CapK04_H,A
mov A,TMRAH
mov a_CapK04_L,A
Note: a_CapK04_H和a_CapK04_L are user defined Data Memory registers
- Question 5
How can the scanning speed be increased for touch keys in the HT45R36 C/R-F?
- Question 6
How can the scanning speed be increased for touch keys in the HT45R34 C/R-F ?
- Question 7
How can the scanning speed be increased for touch keys in the HT45R38 C/R-F ?
- Question 8
In the PCB for the HT45R34/HT45R36 how can the switch stability and noise immunity be improved?
- Question 9
What is the most suitable choice for the RC oscillator frequency in the HT45R34/ HT45R36/HT45R38?
- Question 10
What shapes or forms should touch switches have?
- Question 11
What kind of material can be used to construct touch switches?
- Question 12
What are the requirements for the touch switch covering board material?
- Question 13
What are the covering material thickness requirements for touch switches?
- Question 14
What is the operating principle behind touch switches?
- Question 15
What are the limitations on the area of the capacitor switch?
- Question 16
Can multiple channels in the C/R type MCUs be active at the same time?
- Question 17
Can the HT45RXX be used to implement more touch switches than the maximum number of RC channels?
- Question 18
When using the C/R-F type MCU to implement slide type input PCB layouts are there any special points to note?
- Question 19
What type of software flow is used to implement a sliding type input for the C/R-F type MCU?
- Question 20
The HT45R3X series of touch switches operate without problem in the emulator, but after programming the device the touch switches are not detected?
- Question 21
After Timer A/Timer B overflows is it necessary to read their values immediately?
- Question 22
When using the C/R-F MCU to implement touch switches, what is the normal method of setting up the sensitivity?
- Question 23
There are no PUSH and POP instructions, therefore when entering an interrupt subroutine how is the data backed up?
- Question 24
In the HT45R3x series, how can it be verified if the key has been pressed and what is the actual flow?
Question 1
How can the C/R-F functional block in the HT45R36 be implemented as a capacitive touch switch function?
Answer
The HT45R36 contains a C/R-F functional block. At its centre is an RC oscillator. When this oscillator's external equivalent resistance or capacitance changes, then the oscillation frequency will consequently change.
It is possible to use body capacitance effects to change the C/R-F circuit capacitance value, which will in turn change the oscillation frequency. By detecting a certain value of frequency change, it is possible to detect whether the touch switch (capacitance type) has been touched.
In practical applications it is not necessary to calculate actual frequency values, it is only necessary, within a time fixed by Timer A, to measure difference between the reference frequency (Touch Switch off) Timer B Count and the present Timer B Count. If the difference value meets a previously defined value of sensitivity, then this can be considered as a Touch Switch activation.
The HT45R36 provides 16 C/R sensors with input channels, RC1~RC16, and a signal channel decoder, the program can use the ASCR values (00H~0FH) to select the control switches, TG1~TG16, and subsequently scan the connected touch switches connected to the RC1~RC16 pins.
Question 2
If there are any unused channels among RC1-RC16, the how should they be managed?
Answer
RC1-RC16 are the resistor/capacitor sensor input channels. Only one channel at a time can be connected to the internal RC oscillator. Any unused channels will have no influence on the other used input channels. In managing the hardware of any unused channels, they can simply be left open, in the software it is just necessary to ensure that the channels are not activated.
Question 3
When using the HT45R43/HT45R36 as a touch switch, are there any special considerations for the line from the RC pin to the touch switch?
Answer
To reduce the effects of noise interference, the line from the microcontroller RC pin to the touch switch should be kept as short as possible and should be kept away from other lines, also the optimum line width is from 7 to 10 mil.
Question 4
When using the following instruction to read the contents of the TMRAH and TMRAL registers, the read back data contains errors.
mov A,TMRAL
mov a_CapK04_H,A
mov A,TMRAH
mov a_CapK04_L,A
Note: a_CapK04_H和a_CapK04_L are user defined Data Memory registers
Answer
When reading the contents of TMRAH and TMRAL, it is necessary to first read the high byte and then the low byte, that is first read TMRAH and then read TMRAL. When writing to these registers the order is reversed, that is first write the low byte and then the high byte.
More details on this procedure can be found in the datasheet.
Question 5
How can the scanning speed be increased for touch keys in the HT45R36 C/R-F?
Answer
Within the fixed time unit for Timer A (ex: 5ms), Timer B will also count and by looking at changes determine whether a key has been touched or not. Improvements can be made by changing the number of times the Timer B count changes (ex: 60 times) within the Timer A time, to determine if the key has been pressed or not.
Question 6
How can the scanning speed be increased for touch keys in the HT45R34 C/R-F?
Answer
Within the fixed time unit for Timer A (ex: 5ms), Timer B will also count and by looking at changes determine whether a key has been touched or not. Improvements can be made by changing the number of times the Timer B count changes (ex: 60 times) within the Timer A time, to determine if the key has been pressed or not.
Question 7
How can the scanning speed be increased for touch keys in the HT45R38 C/R-F?
Answer
Within the fixed time unit for Timer A (ex: 5ms), Timer B will also count and by looking at changes determine whether a key has been touched or not. Improvements can be made by changing the number of times the Timer B count changes (ex: 60 times) within the Timer A time, to determine if the key has been pressed or not.
Question 8
In the PCB for the HT45R34/HT45R36 how can the switch stability and noise immunity be improved?
Answer
The CREF, RREF, IN and RCOUT lines should be kept short, and the RC module lines should be kept as close to the MCU as possible. The tracks can be between 10 and 30mil. The RC1-RCXX pin lines must be kept short and fine (7 to 8 mil approx, with a limit of 10 mil) and any vias or pads between them should be made as small as possible. The lines connecting the Key to the RC pin should be identical. The RC1 to RCXX pin lines should be kept away from other components and other lines, with special attention paid to isolation from signal lines. As for the grounding, the Touch Switches should be enclosed by the ground network. The RC1 to RCXX pins should also be separated by a VSS line.

Question 9
What is the most suitable choice for the RC oscillator frequency in the HT45R34/ HT45R36/HT45R38?
Answer
The RC oscillator frequency can be reduced to within 500kHz (connect a 10p capacitor to CREF, default frequency is 500kHz, try to not exceed this frequency), here the noise immunity will also be increased.
 

Question 10
What shapes or forms should touch switches have?
Answer
Touch switches can have circular, rectangular or triangular etc. solid shapes but can also be formed from conducting tracks to give hollow shapes. The former can be used for thicker type overlays while the latter can be used for thinner type of overlays.
Question 11
What kind of material can be used to construct touch switches?
Answer
Suitable material for the construction of touch switches include, PCBs, flexi-circuit boards, and plated membrane conductive glass. Using PCBs provide the most popular material and give the benefits of lower costs, flexi-circuit boards can be used for curved construction applications and can be used with background lighting, while plated membrane conductive glass can be used for screen displays, and combined with user interfaces, however the cost is rather high.
Question 12
What are the requirements for the touch switch covering board material?
Answer
The covering board material must be an insulator which is durable and easy to install with a permitivity value of between 3 and 10 such as standard glass, acrylic, micrite board etc. Covering materials with lower permitivity values will result in touch switches with correspondingly lower sense ranges. It is necessary for the insulating covering to be firmly affixed to the touch switches using a suitable adhesive to remove any air gaps between the switch and covering material.
Question 13
What are the covering material thickness requirements for touch switches?
Answer
The usual thickness of the covering material is from 1mm to 5mm. Thicker materials will result in less sensitive touch switches and lower signal to noise ratio. Switches with lower area will result in lower sense ranges requiring thinner covering material.
Question 14
What is the operating principle behind touch switches?
Answer
The operating principle is that as a finger from a grounded person approaches the touch switch location, the finger and the touch switch together create a capacitance of increasing value, of perhaps several pf in magnitude. This increasing capacitance, if placed within a C/R-F oscillator circuit, will change the value of RC constant and as a result change the frequency of the oscillator. By measuring changes in this frequency it can therefore be determined if a finger has touched or is in the proximity of the touch switch.
Question 15
What are the limitations on the area of the capacitor switch?
Answer
Using the diagram as an example, it is recommended that the switch diameter is not less than 5mm.
Question 16
Can multiple channels in the C/R type MCUs be active at the same time?
Answer
The C/R type MCU type series has four devices, namely the HT45R34/35/36/38. Among these the HT45R34/36/38 have multiple C/R to F converter inputs, which cannot be active at the same time, but can rather only be active one at a time. The conversion value of each channel can be read by polling or by using an interrupt. The multiple channels in the HT45R35 device can be active at the same time. The related touch switch for these active C/R to F conversion channels can only be managed individually.
Question 17
Can the HT45RXX be used to implement more touch switches than the maximum number of RC channels?
Answer
This is possible using an array type of touch switch. The method is as follows:
As shown in the diagram, the crossover point of RCa and RCb forms the touch switch. If at the time when Timer A overflows and generates an interrupt signal, if RCa is active, then after Timer A overflows, the change in the value of Timer B will be greater than the reference value. When RCb is switched on, after Timer A overflows, the change in the value of Timer B will be greater than the reference value, which indicates that the switch has been touched.
Similarly, when Timer B overflows and generates an interrupt, the value in Timer A will also experience a change in value. Using this method can allow higher numbers of touch switch functions, for example the HT4536 can implement 8 x 8 = 64 touch switch inputs.

Question 18
When using the C/R-F type MCU to implement slide type input PCB layouts are there any special points to note?
Answer
The PCB layout schematic drawing is shown in PIC1. (Note: this drawing is only a schematic drawing not a real PCB layout drawing)
PIC1
1. Use multi RC channels with each one related to a touch sense area.
2. Each touch sense area size should be the same to ensure that the basic touch time variance is the same.
3. Each sense area should be close together however between each sense area there should be a VSS line
4. The sense area shape can be decided according to conditions (it is recommend to use the serrated shape shown in the drawing) (Note that in the drawing RCa~RCf show the RC pins corresponding to individual serrated shapes, the green area depicts the VSS network)
Question 19
What type of software flow is used to implement a sliding type input for the C/R-F type MCU?
Answer
1. To scan all of the RC channels to establish the base unit: when the touch sense areas are first scanned and when they are touched, the corresponding code should be written into the buffer
2. The next time the touched sense area is scanned, if the value is not different from the previous one, then the buffer content should not be altered. If it is a neighbouring area to the previous touched area then the slide action can be implemented. Also the value for this touch sense area can be written into the buffer. If the touched area is not a neighbouring area but another area, then no action should be taken and the buffer cleared.
3. At the same time, within a specified time (for example 0.5sec or even less) if no touch action has been detected, then the buffer should be cleared.
4. Repeat the above steps.
See the drawing :
(Note: the get_key() function scans all of the RC channels, when no channels are touched then NULL will be returned, when an RC channel has been touched then the value will be stored in the corresponding ASCR register. The other conditions will return FALSE:
add(1)/sub(1) indicates that the related data should be added or subtracted by 1: tmr_count indicates a timing value, used as a fixed time to renew the base value)
Question 20
The HT45R3X series of touch switches operate without problem in the emulator, but after programming the device the touch switches are not detected?
Answer
This main reason for this problem is that the touch switch channel lines in the emulator and the IC are not the same. Therefore the sensed difference values generated on the emulator and on the IC are not the same. For this reason the adjusted channels on the emulator which can be touch sensed will not necessarily be sensed in the IC.
The most effective way to confirm an effective sense difference value is as follows: if the user PCB has a number display function, then it is only necessary to edit a section of program to display the sensed value. Finally program this sensed difference value into the IC. If the user PCB does not have a number display function, then a display circuit can be constructed to display the sense difference value for each channel. Also the Touch Switch Demo Board (see Application HA0145) can be used to confirm the sensed values.
Question 21
After Timer A/Timer B overflows is it necessary to read their values immediately?
Answer
This is not necessary, as after Timer A/Timer B overflows they will stop running. The RCOCON bit will be automatically cleared to 0 and Timer A/Timer B will not be reset and their values will kept unchanged. Therefore the values of Timer A/Timer B can be read any time after they overflow.
Question 22
When using the C/R-F MCU to implement touch switches, what is the normal method of setting up the sensitivity?
Answer
Reading Timer A when Timer B overflows example:
1. Read the base value. For all untouched switch RC channels set the Timer A values A1~An for the corresponding channel.
2. Read the related RC channel touched switch. Set the related Timer A values as Bn. For example, for the channel RC3 the value read by Timer A will be B3.
3. Read the values of the other switches in the vicinity of the touched switches and store as Cn. For example, when RC4 is touched, then the related neighbouring switch C3 will have the Timer A value C3.
4. Determine if the related switch values, Dn_min and Dn_max meet the conditions
Dn_max >(Bn- An) >Dn_min>(Cn- An). By adjusting the value of Dn_min, the sensitivity of the touch switch can be adjusted.
Because the emulator and actual device are not identical, and because of RC channel connection length and width as well as PCB differences, therefore the emulator can only adjust certain related functions. The obtained sensitivity etc. data and the actual conditions are not exactly the same. Finally the used optimum sensitivity value should be obtained using the actual device and the PCB. Obtaining the above data can be achieved using assistive tools and test program on the actual PCB.
Question 23
There are no PUSH and POP instructions, therefore when entering an interrupt subroutine how is the data backed up?
Answer
Although there are no PUSH and POP instructions, the programmer can still point to the Special Purpose Memory registers whose data could be damaged when an interrupt is generated. First back up the ACC, STATUS and any other registers which require protection. When it is required to return from the interrupt, then restore the previously backed up register data, STATUS and ACC and finally executing the RETI instruction.
MOV R_AccStack, A
MOV A, STATUS
MOV R_StatusStack, A
MOV A, MP0
MOV R_MP0Stack, A
MOV A, MP1 ; if MP1 exists or if there is other protected data
MOV R_MP1Stack, A
…
The following is for the POP operation:
…
MOV A, R_MP1Stack ;if MP1 exists or if there is other protected data
MOV MP1, A
MOV A, R_MP0Stack
MOV MP0, A
MOV A, R_StatusStack
MOV STATUS, A
MOV A, R_AccStack
RETI
(R_AccStack,R_StatusStack,R_MP0Stack,R_MP1Stack are programmer defined Special Purpose Memory RAM BYTE)
Question 24
In the HT45R3x series, how can it be verified if the key has been pressed and what is the actual flow?
Answer
The HT45R3x series, in order to determine if a switch has been effectively touched or not, uses the following process: the touch switch value is obtained from scanning all of the channels. In order to eliminate interference, it is recommended that the switches be scanned again several times to ensure that the switch has been effectively touched. This application scans the switches four times (actually scan can be adjusted according to actual conditions). The flow is shown below:

Points to Note
Question 1
In the HT45 series, when setting up the Timer A overflow to be the R-F converter end flag, it is discovered that before Timer A overflows, Timer B has already overflowed. As this leads to erroneous data being processed, how can this problem be avoided?
Answer
When using the Timer A overflow as the R-F converter end flag, it is important to ensure that before Timer A overflows, Timer B has not overflowed. Otherwise the data will be ineffective. The user can reduce the overflow value in Timer A or increase the value of CREF to ensure that Timer B does not overflow before Timer A does.
Question 2
When using the C language to setup the 16-bit counter TMRA, it is setup using:
_TMRAL=(65536-COUNT)%256;_TMRAH=(65536-COUNT)/256;
however why does the compiler generates a warning?
Answer
When using the C language to setup an initial value in the 16-bit timer, if the following method is used:
_TMRAL=(65536-COUNT)%256;_TMRAH=(65536-COUNT)/256;
then the compiler will have an overflow with constant '65536' warning.
This is because ‘65536’ has already exceeded the 16-bit range. It should be changed to:
_TMRAL=(65535-COUNT+1)%256;_TMRAH=(65535-COUNT+1)/256;
to eliminate the error message.
Question 3
How are the TMRAH/TMRBH and TMRAL/ TMRBL registers correctly written to?
Answer
When writing to TMRAH/ TMRBH and TMRAL/ TMRBL, the following setup procedure should be carried out:
1. Switch off the external RC oscillator counter (RCOCON = 0)
2. Switch on the RC oscillator (RCO = 1)
3. When writing, ensure that the low byte is written to before the high byte (first write to TMRAL/TMRBL after which TMRAH/TMRBH should be written)
If any of the above setup steps are incorrectly implemented than it will not be possible to correctly write values to TMRAH/ TMRBH and TMRAL/ TMRBL.
Question 4
When using the RC channel in the 20-pin HT45R35, what points should be noted?
Answer
Because pins RC3, RC4, RC9 and RC10 are shared with the PA and PA port pins, if these four RC channels are to be used, in addition to choosing the correct configuration options to select the RC inputs, it is also necessary to setup the pin as an input using the application program, otherwise Timer B will have no clock input.
|