Basic Information Functional Description Application Description Points to Note Others

Basic Information

 

Question 1

What are the contents of the HT46 A/D type MCUs?

Answer

The HT46 series of A/D type MCUs have a selection of 1K,  2K, 4K, 8K and 16K OTP and Mask Type memory capacities. Among the series, the HT46R22/HT46C22, HT46R23/HT46C23, HT46R24/HT46C24 and HT46R25/HT46C25 devices also incorporate an I2C serial I/O interface. The HT46R51A, HT46R52A, HT46R53A and HT46R54A devices have a 12-bit A/D converter. For more information please consult the relevant datasheet.


Question 2

What are the differences between the various devices in the HT46 A/D type MCUs?

Answer

Please check on the table below for the differences. For more detailed information consult the data sheet.
Part No. VDD System
Clock
Program
Memory
Data
Memory
I/O 8-bit
Timer
Interrupt A/D PWM PFD Stack Package
Ext. Int.
HT46R02* 2.2V~
5.5V
400kHz~
12MHz
2Kx14 96x8 8 2 1 3 9-bitx4 8-bitx1 v 6 10MSOP
HT46R03* 2.2V~
5.5V
400kHz~
12MHz
4Kx15 160x8 8 2 1 3 12-bitx4 8-bitx1 v 6 10MSOP
Part No. VDD System
Clock
Program
Memory
Data
Memory
I/O Timer Interrupt I2C A/D PWM PFD UART Stack Package
8-bit 16-bit Ext. Int.
HT46R22
HT46C22
2.2V~
5.5V
400kHz~
8MHz
2Kx14 64x8 19 1 -- 1 3 v 9-bitx8 8-bitx1 v -- 6 24SKDIP,
24SOP
HT46RU22 v
HT46R23
HT46C23
2.2V~
5.5V
400kHz~
8MHz
4Kx15 192x8 23 -- 1 1 3 v 10-bitx8 8-bitx2 v -- 8 24SKDIP,
24SOP,
28SKDIP,
28SOP
HT46R232
HT46C232
2.2V~
5.5V
400kHz~
8MHz
4Kx16 192x8 40 -- 2 1 4 v 10-bitx8 8-bitx4 v -- 8 28SKDIP,
28SOP,
48SSOP
HT46R24
HT46C24
2.2V~
5.5V
400kHz~
8MHz
8Kx16 384x8 40 -- 2 1 4 v 10-bitx8 8-bitx4 v -- 16 28SKDIP,
28SOP,
48SSOP
HT46RU25
HT46CU25*
2.2V~
5.5V
400kHz~
8MHz
16Kx16 576x8 48 1 2 1 5 v 12-bitx8 8-bitx4 v v 16 48SSOP,
56SSOP
Part No. VDD System
Clock
Program
Memory
Data
Memory
I/O 8-bit
Timer
Interrupt A/D PWM PFD Stack Package
Ext. Int.
HT46R46-H 3.3V~
5.5V
400kHz~
8MHz
1Kx14 64x8 13 1 1 2 8-bitx4ch 8-bitx1 v 4 18DIP/SOP
HT46R47-H 3.3V~
5.5V
400kHz~
8MHz
2Kx14 64x8 13 1 1 2 9-bitx4ch 8-bitx1 v 6 18DIP/SOP
Part No. VDD System
Clock
Program
Memory
Data
Memory
I/O 8-bit
Timer
Interrupt A/D PWM PFD Stack Package
Ext. Int.
HT46R51A 2.2V~
5.5V
400kHz~
8MHz
1Kx15 96x8 14 1 1 2 12-bitx5 8-bitx1 v 6 18DIP,
20SOP/SSOP
HT46R52A 2.2V~
5.5V
400kHz~
8MHz
2Kx15 128x8 14 1 1 2 12-bitx5 8-bitx1 v 6 18DIP,
20SOP/SSOP
HT46R53A 2.2V~
5.5V
400kHz~
8MHz
2Kx15 192x8 22 1 1 2 12-bitx8 8-bitx1 v 6 28SKDIP/SOP
HT46R54A 2.2V~
5.5V
400kHz~
8MHz
4Kx15 208x8 22 1 1 2 12-bitx8 8-bitx1 v 6 28SKDIP/SOP
Part No. VDD System
Clock
Program
Memory
Data
Memory
I/O 8-bit
Timer
Interrupt A/D Comparator PPG PFD Stack Package
Ext. Int.
HT46R12A 2.2V~
5.5V
400kHz~
8MHz
2Kx14 88x8 16 2 2 3 9-bitx4 2 1 v 8 24SKDIP,
24SOP
HT46R14A 2.2V~
5.5V
400kHz~
8MHz
4Kx15 192x8 20 2 3 3 9-bitx8 2 2 v 8 28SKDIP,
28SOP


Question 3

What are the various packages available in the HT46 A/D type MCUs?

Answer

Please see table below. Mask type MCU HT46CXX have the identical packaging forms.

HT46R22 : 24 SKDIP & SOP
HT46R23 : 24 SKDIP & SOP (compatible pinouts with the HT46R22 for convenient MCU upgrade)
28 SKDIP & SOP
HT46R24 :  28 SKDIP & SOP (compatible pinouts with the HT46R23 for convenient MCU upgrade)
48 SSOP
HT46R25 :  48/56SSOP
HT46R51A: 18 DIP
20 SOP & SSOP 
HT46R52A : 18DIP (compatible pinouts with the HT46R51A for convenient MCU upgrade)
20 SOP & SSOP (compatible pinouts with the HT46R51A for convenient MCU upgrade)
HT46R53A :  28 SKDIP & SOP 
HT46R54A :  28 SKDIP & SOP (compatible pinouts with the HT46R53A for convenient MCU upgrade)

Question 4

What is the operating frequency of the HT46 A/D type MCUs?

Answer

For 5V/3.3V or 3-cell battery applications, the maximum operating frequency is 8MHz (3.3V). For 3V or 2-cell battery applications the maximum operating frequency is 4MHz (2.2V)


Question 5

What is the system frequency tolerance if an RC oscillator is used as the system clock?

Answer

If the RC oscillator is selected, due to tolerances in the device processing, a nominal ±20% frequency tolerance from lot to lot is expected. Assuming that the external resistor has a ±5% tolerance, then the overall frequency tolerance would be ±25%.

The above specified tolerance is provided as a reference only and is not guaranteed. For applications where a more precise frequency source is required it is recommended that either a resonator or crystal frequency source is used.


Question 6

When using assembly language for the HT46R4 device, which is a Multi Ram Bank MCU, is it possible to directly implement a direct address operation for variables defined in banks other than BANK 0?

Answer

This is not possible. In assembly language, even if the BP can be directly addressed, direct addressing only applies to registers in BANK 0. For Banks other than BANK 0, the MP1 Memory Pointer must be used to access any registers located here.


Question 7

Why does the 18-pin DIP-A package for the HT46R51A/HT46R52A not have a VREF pin?

Answer

The HT46R51A and HT46R52A devices have two package types, an 18-pin DIP-A and 20-pin SOP-A/SSOP-A. On the 18-pin package, the VREF pin is connected internally to the VDD pin, therefore externally there is no VREF pin, whereas on the 20-pin package there is an external VREF pin.


Functional Description

 


Question 1

How to use the indirect memory addressing mode?

Answer

First the address to be read or written must be placed in the relevant memory pointer, known as MP. After this any instruction that refers to the Indirect Register, known as IAR, (e.g. MOV a, IAR) will result in action taking place on data pointed to by the memory pointer (MP). Indirect memory addressing is particularly useful for operations on data arrays by first placing the first array address in the memory pointer. Data can then be read or written from different places in the array by manipulating the data pointer.


Question 2

What are the special features and characteristics of the HT46 A/D type MCUs?

Answer

Operating Voltage range of 2.2V ~ 5.5V
Industrial standard temperature range of -40°C ~ +85°C
Low Voltage Reset function
Fully compatible OTP and Mask Types
For further details consult the relevant Holtek data sheet


Question 3

The HT46R23/HT46C23 have two memory pointers, what is the difference between them?

Answer

MP0/IAR0 and MP1/IAR1 are pairs of registers that need to be used together. MP0/IAR0 can only be used by RAM BANK 0 while MP1/IAR1 can be used by any RAM BANK.


Question 4

How are the table read instructions used and are there any special points to note?

Answer

There are two kinds of table read instructions, the first is the TABRDC instruction which is used to read data from the present program memory page. The second is the TABRDL statement which can read data from the last page of program memory. When reading data from tables it is first necessary to place the low byte of the program memory address where the data is stored, into the table pointer register TBLP. The table read instruction can then be executed which will place the low byte of the table data into the register indicated by the table read instruction. The high byte of the table data will be placed into the TBLH register. Note that the highest unimplemented bits in the data high byte will read as "0".


Question 5

What is the difference between choosing the WDT oscillator or the fSYS/4 clock as the WDT clock source?

Answer

If the WDT oscillator clock is chosen as the clock source then if the system enters a HALT condition the WDT timer will continue to function. When the WDT time-outs the system will be woken up from its HALT state. If the fSYS/4 clock is chosen as the WDT clock source then the WDT will cease to function and system will not be woken up when a HALT state is entered. The cost in choosing the WDT oscillator is that some power will be consumed by its clock. For systems that operate with HALT feature and need not to be woken up from HALT by WDT overflow, in this case the fSYS/4 clock source should be selected.


Question 6

How is the 8-bit timer setup?

Answer

The 8-bit timer/counter is a count up timer which upon reaching a count of 255 (0FFH) will reset itself to 00H and generate an internal interrupt signal. To obtain different timer counts, say N, of less than 256, the timer should be first preset with a fixed value of 256-N. After setting up this preset value the timer should be activated which will enable it to count from this preset value to 255. The value that the timer is to count N, is therefore given by the formula 256-(256-N)=N.


Question 7

How is the 16-bit timer setup?

Answer

The 16-bit timer/counter is a count up counter, which upon reaching a value of 65535 (0FFFFH) will reset itself to 0000H and generate an internal interrupt signal. To obtain different timer counts, say N, of less than 65536, the timer should be first preset with a fixed value of 65536-N. After setting up this preset value the timer should be activated which will enable it to count from this preset value to 65535. The value that the timer is to count N, is therefore given by the formula 65536-(65536-N)=N.


Question 8

What is the access sequence of the 16-bit Timer/Counter?

Answer

For the HT46 A/D type MCU, the internal data bus is 8-bit wide, therefore for the 16-bit Timer/Counter, the user has to write the Low Byte data first and then write the high byte data. To read the Timer/Counter contents, the user has to first read the High Byte data first and then the Low Byte data.


Question 9

When the 8-bit Timer/Counter clock is sourced from the Prescaler, can the Prescaler be reset?

Answer

The Prescaler will start to count after a Power On Reset, so there is no means for the user to reset the Prescaler contents.


Question 10

How is 8-bit Timer/Counter setup in the Timer Mode?

Answer

There are three modes available for the 8-bit Timer/Counter, i.e. Timer Mode, Event Counter Mode and Pulse Width Mode. To setup in the Timer Mode, the following process should be followed:

  1. Set to Timer Mode by writing 10H to TM1, TM0

  2. According to the user timer period requirements set the Prescaler by writing the appropriate values to the bits PSC2~PSC0

  3. Set the initial timer TMR value

  4. Enable the corresponding interrupt by setting the ETI and EMI bit

  5. Start the Timer by setting the TON bit of the TMRC

Once the Timer is enabled, it will count up and will be stopped when the TON bit in the TMRC register is cleared. If the Timer is enabled once again, the counter will start counting from the value where it was stopped. If the Timer overflows, an internal interrupt request will be issued and the TMR will be reloaded with the initial value.


Question 11

How is 16-bit Timer/Counter setup in the Timer Mode?

Answer

There are three modes available for the 16-bit Timer/Counter, i.e. Timer Mode, Event Counter Mode and Pulse Width Mode. To setup in the Timer Mode, the following process should be followed:

  1. Set to Timer Mode by writing 10H to TM1, TM0

  2. Set the initial timer TMR value

  3. Enable the corresponding interrupt by setting the ETI and EMI bit

  4. Start the Timer by setting the TON bit of the TMRC

Once the Timer is enabled, it will count up and will be stopped when the TON bit in the TMRC register is cleared. If the Timer is enabled once again, the counter will start counting from the value where it was stopped. If the Timer overflows, an internal interrupt request will be issued and the TMR will be reloaded with the initial value.


Question 12

How is the Timer/Counter setup in the Event Counter Mode?

Answer

There are three modes available for the Timer/Counter, i.e. Timer Mode, Event Counter Mode and Pulse Width Mode. To set in the Event Counter Mode, the following process should be followed:

  1. Set to Event Counter Mode by writing 01H to TM1, TM0

  2. Select TE=1 to count on the falling edge and TE=0 to count on the rising edge

  3. Set the Timer initial value into TMR

  4. Enable the corresponding interrupt by setting the ETI and EMI bits

  5. Start the Timer by setting the TON bit in the TMRC register


Question 13

How is the 8-bit Timer/Counter setup in the Pulse Width Mode?

Answer

There are three modes available for the Timer/Counter, i.e. Timer Mode, Event Counter Mode and Pulse Width Mode. To set in the Pulse Width Mode, the following process should be followed:

  1. Set to Pulse Width Mode by writing 11H to TM1, TM0

  2. Select TE=1 to measure a High Pulse Width and TE=0 to measure a Low Pulse Width

  3. According to the Pulse Measurement width requirements set the Prescaler value ( PSC2~PSC0=n)

  4. Set the Timer initial value, TMR, usually set to 0H for Pulse Width Measurements

  5. Enable the corresponding interrupt by setting the ETI and EMI bits

  6. Start the Timer by setting the TON bit in the TMRC

After the Timer/Counter is enabled, the user can poll the TON bit, if one pulse measurement is complete, the TON bit will be cleared to 0 and the count value multiplied by 2n is the measured pulse width.


Question 14

How is the 16-bit Timer/Counter setup in the Pulse Width Mode?

Answer

There are three modes available for the Timer/Counter, i.e. Timer Mode, Event Counter Mode and Pulse Width Mode. To set in the Pulse Width Mode, the following process should be followed:

  1. Set to Pulse Width Mode by writing 11H to TM1, TM0

  2. Select TE=1 to measure a High Pulse Width and TE=0 to measure a Low Pulse Width

  3. Set the Timer initial value, TMR, usually set to 0H for Pulse Width Measurements 

  4. Enable the corresponding interrupt by setting the ETI and EMI bits

  5. Start the Timer by setting the TON bit in the TMRC

After the Timer/Counter is enabled, the user can poll the TON bit, if one pulse measurement is complete, the TON bit will be cleared to 0 and the value in the counter will be the pulse width measured.


Question 15

How is the HT46X22 8-bit PFD setup?

Answer

To utilize the PFD function of HT46X22, the following process should be followed:

  1. Choose PFD enabled in the configuration option

  2. Set the Prescaler (PSC2~PSC0=n) value and TMR initial value from the formula fPFD = (fSYS / (2nx(256-TMR)x2))

  3. Start the Timer by setting the TON bit in the TMRC

  4. Set PA bit 3 in Output Mode, i.e.PAC.3=0

After these steps are taken, set PA.3=1 to turn on the PFD and PA.3=1 to turn off the PFD.


Question 16

How is the HT46X23 16-bit PFD setup?

Answer

To utilize the PFD function of HT46X23, the following process should be followed:

  1. Choose PFD enabled in the configuration option

  2. Set the TMR initial value from the formula fPFD = (fSYS / ((65536-TMR)x2))

  3. Start the Timer by setting the TON bit in the TMRC

  4. Set PA bit 3 in Output Mode, i.e.PAC.3=0

After these steps are taken, set PA.3=1 to turn on the PFD and PA.3=1 to turn off the PFD.


Question 17

What is the PWM frequency under (6+2) mode and (7+1) mode?

Answer

For PWM (6+2) mode, the PWM cycle is divided into 4 modulation cycles. Each modulation cycle has 64 PWM input clock periods, and the PWM frequency will be fSYS/26. For PWM (7+1) mode, the PWM cycle is divided into 2 modulation cycles. Each modulation cycle has 128 PWM input clock periods, and the PWM frequency will be fSYS/27. In comparison with the 8-bit mode, the (6+2) Mode PWM frequency is 4 times higher and (7+1) mode is 2 times higher than that of the 8-bit mode.


Question 18

What are the HT46 A/D type MCU I2C Bus features?

Answer

Except HT46X47, the HT46 A/D Type MCU series is featured with slave mode I2C Bus. Via SCL and SDA lines, MCU can receive data or transmit data upon Master device's request.


Question 19

How to calculate the A/D Conversion clock frequency?

Answer

Each A/D conversion needs 76 AD clocks which is selected by ADCS1and ADCS0. Please refer to the table:

ADCS1 ADCS0 TAD Frequency
0 0 fSYS/2
0 1 fSYS/8
1 0 fSYS/32
1 1 Undefined

Question 20

How is the ADCLK calculated and what are its restrictions?

Answer

For the HT46 A/D Type MCUs, the minimum A/D Clock Period (tAD) is 1us. Therefore, the A/D Clock Period chosen by programming bits ADCS1 and ADCS0 must be carefully chosen to ensure that the selected A/D clock period is not less than 1us. The values are shown in the table below:

fSYS

A/D Clock Period (tAD)

ADCS1, ADCS0 = 00
(fSYS/2)
ADCS1, ADCS0 = 01
(fSYS/8)
ADCS1, ADCS0 = 10
(fSYS/32)
ADCS1, ADCS0 =11
1 MHz 2 us 8 us 32 us Undefine
2 MHz 1 us 4 us 16 us
4 MHz *500 ns 2 us 8 us
8 MHz *250 ns 1 us 4 us

* indicates the ADCS1 and ADCS0 bit settings that are not permitted as they will give a tAD value that is less than 1us .


Question 21

How long is the A/D sampling time?

Answer

The A/D Sampling Time requires 32tAD. For example, if the A/D Clock Period is 4us, then the A/D Sampling Time will be 128us.


Question 22

What is the equivalent circuit of the A/D type MCU to its external analog signal source?

Answer

The equivalent circuit of the A/D type MCU to its external analog signal source is drawn as below:

Notations:
VA : external analog signal source
RA : external analog signal output impedance
AN0~AN7 : analog signal input pins
CPIN : analog signal input pin input capacitance CPIN = 5pF
D1, D2 : protection diodes on pad, VT=0.6V
II  : leakage current on pad, II  = ±1μA (max.)
SS : analog signal sampling switch
RSS : analog signal sampling switch equivalent impedance; ca.100/200Ω at 5V/3V
CS/H : sampling and hold capacitance shown as below;

  HT46R23, HT46R24, HT46R64, HT46R65  HT46C23, HT46C24, HT46C64, HT46C65 HT46R47, HT46R22, HT46R62 HT46C47, HT46C22, HT46C62 HT46R63 HT46C63
CS/H 225.3pF 94.2pF 112.6pF 71.3pF 56.32pF 35.6pF
A/D resolution 10-bit 10-bit 9-bit 9-bit 8-bit 8-bit
A/D conversion time 76tAD 76tAD 76tAD 76tAD 64tAD 64tAD
A/D sampling time 32tAD 32tAD 32tAD 32tAD 32tAD 32tAD

Note: tAD is the A/D clock period detailed in the datasheet.


Question 23

The HT46R23 and HT46R24 have 2 and 4 PWM channels respectively. By writing the same values into the PWM registers and enabling them at different times, will PWM output waveforms with different phases be generated?

Answer

No, PWM waveforms with different phases will not be generated as the waveforms are derived from the same PWM counter.


Question 24

When using the HT46R22 with a 4MHz system clock, what is the frequency of the source clock for the internal timer?

Answer

The internal timer source clock frequency for this device is the same as the system clock, therefore in this case it is 4MHz.


Question 25

What is the function of the WDT?

Answer

The WDT is designed to monitor the MCU software and hardware operations. Users should employ the CLEAR WDT (CLR WDT or CLR WDT1 and CLR WDT2 ) instructions should any abnormal operation or malfunction happens when a WDT overflow would occur which will then reset the MCU to resume normal operation. The WDT monitoring effects mainly depend on the software program design.


Question 26

Is the value of conversion in the 8-bit A/D MCUs equal to N*Vref/255 or N*Vref/256?

Answer

Because the conversion value is of a discrete nature, it does not express an absolute value, it rather expresses a range instead. For example "0" can indicate a voltage between 0 Volts and Vref/256 while "1" can indicate a voltage between Vref/256 and 2Vref/256 etc. When using the N*Vref/256 formula, the largest error value will be Vref/256. When using the N*Vref/255 formula, the error lies between a value of -Vref/256 and Vref/256. In both cases the actual error range is the same. Therefore both the /255 or /256 value are acceptable.


Question 27

Many of the Holtek MCUs have a Low Voltage Reset function. When this operates what is the condition of the I/O, OSC pins etc?

Answer

When the power supply voltage falls below the specified LVR voltage, the LVR function will be activated. When this happens the I/O pins will revert to an input condition, and the oscillator will start up. The LVR voltage will vary according to the process, for details consult the DC characteristics section of the datasheet.


Question 28

What is the difference between the activation of an LVR function and pulling the RES pin low?

Answer

The difference is that in the case of the LVR, if the operating voltage falls below the LVR voltage but remains higher than the lowest operating voltage, the oscillator will continue running. However if the RES pin is pulled low the oscillator will be always be stopped.


Question 29

In the HT46R65, how can variables in bank2 be defined? When the data db is used to define variables, when the number of variables exceeds 192, the compiler generates an "exceed RAM capacity error message." 

Answer

It is necessary to use the RAMBANK banknum section-name[,section-name,...] to declare the data memory sections. This directive is used to declare the data sections in the data memory block.

banknum defines the number of the data memory divisions, the range is from 0 to the maximum size of data memory block. section-name is name given to the previously defined data memory divisions. This enables more than one section to be declared within the same data memory blocks.

For more details on how to use this consult the following: 
http://www.holtek.com.tw/english/literature/ht-ide3k.pdf


Question 30

Can all pins on the HT46R22 be used as A/D inputs? Can any remaining pins be used as I/O pins?

Answer

The ADCR register is used to determine which pins are to be used as A/D inputs and which are to be used as I/O pins. If the PCR2, PCR1 and PCR0 bits in the ADCR register are set to "1XX" then all PB pins will be used as A/D inputs. If these bits are set to "001" then only PB0 will be used as an A/D input, the other PB pins will be used as standard I/O pins. For more details see the following table:

Name(ADCR)

Bit 

Function

ACS0
ACS1
ACS2

0
1
2

ACS2,ACS2,ACS0:A/D channel choice
0,0,0:AN0
0,0,1:AN1
0,1,0:AN2
0,1,1:AN3
1,x,x:undefined, do not use

PCR0
PCR1
PCR2

3
4
5

PCR2,PCR1,PCR0:PB3~PB0 definition
0,0,0:PB3,PB2,PB1,PB0
0,0,1:PB3,PB2,PB1,AN0
0,1,0:PB3,PB2,AN1,AN0
0,1,1:PB3,AN2,AN1,AN0
1,x,x:AN3,AN2,AN1,AN0

EOC

6

A/D conversion end flag(0:A/D conversion ended)

START

7

A/D conversion start control
0→1→0:start
1→0:A/D conversion reset, set to "1"


Question 31

The HT46R22 RAM space exists in the range 0x40--0x7f, however as the system has 6 stack levels, do they also exist within this 0x40--0x7f area?

Answer

The stack area has its own memory space and does not lie within the RAM or ROM memory area.


Question 32

In the HT46R47 is it possible not to use the A/D interrupt? After initiating a START pulse, by looking at the EOC flag to see if it has been reset to zero, can I determine that the conversion had ended?

Answer

Yes, this is possible.


Question 33

What are the special features of the UART in the HT46RU25?

Answer

The UART uses full duplex asynchronous communication, and can choose either an 8 or 9-bit character length, with odd or even parity and with a choice of either one or two stop bits. The UART also has its own baud rate generator with an 8-bit frequency division register, various error checking functions as well as various interrupts and address checking. There is also a two level FIFO receiver buffer as well as transmit and receive interrupts.


Question 34

What are the conditions for the generation of a UART interrupt?

Answer

When the UART meets any of the following conditions, an interrupt will be generated: when a transmission has ended, when the transmit register is idle, when a data reception has ended, the occurrence of an overrun error or an address match.


Question 35

How can the HT46RU25 UART serial data transmission frequency be calculated?

Answer

The UART function contains an internal baud rate generator which is controlled by both the BRG register and bit 2 of the UCR2 register which is known as the BRGH bit. If the BRGH bit is set to "0" the baud generator frequency will be governed by the equation Fsys/[64*(N+1)]. If the BRGH bit is set to "1" the baud generator frequency will be governed by the equation Fsys/[16*(N+1)]. The value of N is from 0~255.


Question 36

Why is it when I use the Baud Rate formula to calculate the Baud Rate it is different from the actual rate?

Answer

According to the Baud Rate formula, the value of N that is calculated will be a normal floating point number. However the actual value that will be placed into the BRG register will be the closest value to this number and not the actual value. Because of this it is difficult to avoid errors between the actual value and the theoretical value.


Question 37

What is the transmit and receive data types and waveforms for the UART?

Answer

For the transmit and receive mode consult the following table.


For the data waveforms consult the following diagram.


Question 38

What are the steps to initialise the UART?

Answer

1. Setup the BN0, PRT, PREN and STOPS bits to determine the data length, parity type and stop bit length.
2. Setup the BRG register to determine the Baud Rate.
3. Set the TXEN bit to enable the UART function.


Question 39

What steps are required to initialise the UART receiver?

Answer

1. Setup the BN0, PRT, PREN and STOPS bits to determine the data length, parity type and stop bit length.
2. Setup the BRG register to determine the Baud Rate.
3. Set the RXEN bit to enable the UART function. AT this point the UART will await the detection of the first bit.
4. After normal reception of the data, the USR register can be read, this action will clear the RXIF bit.
5. Read the received data from the RXR register.


Question 40

What is the meaning of an overrun error in the UART function, and if it occurs how does the UART handle such an error?

Answer

The RXR register is a two level FIFO buffer area, where two bytes can be held while another third byte is being received. The application program needs to read the RXR register before the third data byte has been completely received, otherwise an overrun error will occur. When such an error occurs the following will take place: the OERR bit in the USR register will be set, the data in the RXR register will not be discarded and the RSR register data will be overwritten. Also if the RIE bit is set to 1, an interrupt will occur.


Question 41

How many registers does the UART have and what functions do they have?

Answer

The UART function has 5 associated registers known as USR, UCR1, UCR2, BRG and TXR/RXR. The USR is the UART's status register, which is read only and can be read using the program. The UCR1 and UCR2 registers are the control registers for the UART and are used to define the UART functions, such as the enable/disable, odd or even parity, transmission data length etc. 
The main function of the UCR2 register is to enable or disable the transmit or receive functions as well as the interrupt enable functions. It also controls the Baud Rate and enables or disables the receive data wake-up bit. 
The BRG register is used to setup the Baud Rate. The value of BRG is related to the condition of BRGH. 
The TXR/RXR register is used for the transmit and receive data.


Question 42

How does the UART transmit data?

Answer

When the UART is transmitting data, the data will be transferred from the shift register to the TX pin, starting with the LSB and ending with the MSB. When in the transmit mode, the internal TXR register and the shift register form a FIFO buffer. If the 9-bit data option is chosen, the MSB will be stored in bit TX8 of the UCR1 register.


Question 43

What kinds of receive errors does the UART generate?

Answer

The UART will generate four kinds of receive errors which are Overrun Error, Noise Error, Framing Error and Parity Error.


Question 44

How is the RAM in the HT6R454A and HT46R54 differentiated?

Answer

The HT46R54 has a RAM structure of 88 X 8, with memory pointers MP0 and MP1, 7-bits wide. The HT46R54A has a structure of 280 X 8 with MP0 and MP1 8-bits wide.


Question 45

Can the LVR be simulated in the ICE?

Answer

The ICE has a fixed VDD voltage of 5V, therefore it is not possible to simulate the operation of the LVR.


Question 46

What are the differences between the HT46R49E and the HT46R49?

Answer

The HT46R49E device uses modern packaging techniques to combine two chips into a single package. One device is the HT46R49 and the other device is a 1K bit Data EEPROM.
This category of products can reduce packaging costs and supply the user with a more economical solution in addition to reducing circuit board area, making it suitable for devices with space constraint limitations. Both the HT46R49 and HT46R49E are supplied in 24/28 pin SKDIP and SOP package forms.


Question 47

When the Timer/Counter has been started and is running, can data be written to it?

Answer

Yes this is possible, however any new data written to the timer will be first stored in the preload registers and not loaded immediately to the timer registers. When the next counter overload occurs the data will be written to the timer registers.


Question 48

Can more than one A/D converter channel in the AD type MCUs be open at one time?

Answer

This is not possible. However a polling method can be used to open each channel and then use interrogating or interrupt methods to read back the value.


Application Description

 


Question 1

As there are no Push and POP instructions, when an interrupt occurs how is the data backed-up?

Answer

Although there are no PUSH or POP instructions, the programmer can still assign memory space. (Example db: ACCStack for ACC Storage) to store the interrupt backup data. To do this first store the ACC data in an area of memory, after which the status register and other data to be stored can be stored in similar dedicated memory locations. Before returning to the main program the data should be retrieved similarly but in a reverse order i.e. ACC is the last to be retrieved. When this is completed a RETI instruction should be executed to return to the main program.


Question 2

Can the Call instruction be used within an interrupt routine?

Answer

Because of the limitations in size of the MCU Stack, programmers must be exceptionally careful if using a call instruction inside an interrupt routine. If the program is in an interrupt routine and the stack is full, then executing a call instruction will result in a stack-over situation preventing the program from returning properly from the interrupt routine. Therefore if it is necessary to execute call instruction from within interrupt routines it is imperative that the worst case condition regarding stack requirements are considered. Before entering interrupt routines it is essential to verify that enough stack levels are available.


Question 3

When an interrupt is being serviced will other occurring identical interrupts be effective?

Answer

In normal operation when the MCU enters an interrupt routine the EMI flag will be cleared (EMI=0), which will prevent any corresponding interrupts from being serviced. However if the program is used to actively set the EMI flag (EMI=1) when an interrupt is being serviced then if the stack is not full, all other interrupts (including identical interrupts) will be effective. If multiple interrupts are necessary the programmer must take great care to ensure that the backed up data from the present interrupt is not corrupted by any following interrupts. Unless in cases of absolute necessity it is strongly recommended that multiple interrupts are not permitted.


Question 4

How should unused I/O pins be managed?

Answer

Any unused I/O pins should be managed properly so as to prevent from power consuming. The best method to prevent this is to set any unused pins as outputs however if set as inputs they should be selected to have a pull up option. If a pull-high option is not used then the pin should be tied to ground.


Question 5

Why, when PA is low the device cannot wake up?

Answer

The PA port pins can all be configured to wake up the device but are activated only on a low going edge. If the corresponding PA pin was low when the HALT instruction was executed then the low logic state of this pin will have no wake up effect as no low going transition exists.


Question 6

Why, when a low going edge is presented on the external interrupt pin the MCU does not wake-up?

Answer

Although the MCU can be woken up by an external interrupt, the actual wake process takes place only when the Interrupt Request Flag EIF changes from "0" to "1". If when the MCU enters a HALT condition the EIF flag is already set to "1", then a further interrupt will have no effect on the status of the EIF flag, which will remain in its present "1" condition. As a transition a wake-up will not occur.


Question 7

Is it possible to disable the wake-up function of the external interrupt?

Answer

If before entering a HALT condition the EMI is first cleared and then if the EIF bit is set to "1" the external interrupt will have no wake-up function.


Question 8

What is the purpose of 2 CLR WDT instructions?

Answer

Two CLR WDT instructions feature increases the system reliability. If the program contains two loops in the main program a CLR WDT1 instruction can be placed in one loop and a CLR WDT2 instruction in the other loop. If a malfunction occurs, perhaps due to noise, and the program enters an infinite loop none of the CLR instructions in the other loop will be executed, therefore the WDT will overflow and generate a reset signal to reset the MCU.


Question 9

How is the HT46 A/D type MCU PWM setup?

Answer

First choose PWM in the configuration option. Set PDC.0=0 to enable PWM function and write the PWM output value to the PWM Register. Set PD.0=0, PWM outputs 0; set PD.0=1, PWM outputs PWM. If a secondary PWM is used, it is controlled by PDC.1 and PD.1.


Question 10

How is the HT46 MCU A/D Converter setup?

Answer

To utilize the HT46 MCU A/D Converter, the following process should be followed: 

  1. Configure Port B A/D Converter channels by setting PCR2, PCR1 and PCR0

  2. Select the channel for A/D conversion by setting ACS2, ACS1 and ACS0. Note the channel selected should be configured in the previous step.

  3. Set ADCR.7=0 -->1-->0 to start the A/D conversion, EOCB=1 indicating A/D conversion is in process.

  4. Wait 76 TAD periods to complete the A/D conversion, EOCB=0 indicating the end of A/D conversion and interrupt request flag ADF=1

  5. Read the conversion results in the ADRL and ADRH Registers.


Question 11

How is the HT46 A/D Type MCU I2C Bus setup?

Answer

First set the salve address in the HADR Register, and enable the I2C Bus by setting HEN=1 and enable interrupt EHI=1. Now is ready to receive the address transmitted via SDA line. If the address matches the address stored in HADR Register, the HASS bit=1 and the ACK acknowledgement will be automatically issued to the Master device and HIF I2C Bus interrupt request flag will be set.

If the Master device requests data reading, set the HTX=1 and then data stored in the HDR Register will be transmitted. If the Mater device requests data writing, then a dummy data read from HDR Register to enable data receiving. In short, the I2C Bus can receive, compare salve address and acknowledge automatically in accordance to Master device's SCL signals, user can just easily read and write the HDR Register. For more detailed information consult the data sheet.


Question 12

For 2-cell battery applications (2.2V~3.8V), is the Low Voltage Reset (LVR) still available?

Answer

For the HT46 A/D Type MCUs, the Low Voltage Reset (LVR) function operates in the range of 2.7V ~3.3V, therefore the LVR feature is not applicable. If a 2.2V voltage detection function needed in applications, an external Voltage Detector (HT70XX) is recommended.


Question 13

The system frequency is 4MHz and the ADCLK is fSYS/32 , why is the A/D conversion to a 250 us square wave sometimes incorrect?

Answer

For the HT46 A/D Type MCU, the A/D conversion time is 76tAD with 32tAD S&H in advance. For details see the Timing diagram below. If the system frequency is 4MHz and the ADCLK is fSYS/32, the Sampling Time will be 32tAD = 256us. Since the ADCLK scaler is a free-running counter, the A/D Sampling Time ranges from 31~32 ADCLK, i.e., 248us<A/D S&H time<256us, which will sometimes result in an incorrect A/D conversion value. The user can correct this problem by selecting the ADCLK to be fSYS/8, which will shorten the A/D Sampling Time to a value of 64us .


Question 14

For Holtek's MCUs, is there any way to reset the stack pointer other than by a chip RESET?

Answer

The stack pointer is affected by the execution of interrupts as well as by any subroutine calls which occur in the application program. In addition, any return instructions will also affect the stack pointer. However, it is not possible for the user to directly reset the stack pointer by any means other than the chip RESET.


Question 15

If the RC oscillator is selected as the system clock, what are the purposes of the external resistor and capacitor? Can the capacitor be omitted?

Answer

The external resistor on the OSC1 pin is used to generate bias to control the internal RC charge and discharge. The frequency of the RC oscillator is determined by the value of this external resistor. The recommended 470pF external capacitor, which is connected to the OSC1 pin, is added to avoid cross-talk to the OSC2 line. The OSC2 pin is provided to supply an output frequency of 1/4 system frequency. However, if this 1/4 system frequency output, OSC2, is not utilized, the external capacitor on OSC1 pin can be omitted.


Question 16

How to decide the RA value?

Answer

Take 5V, 10-bit A/D for example, the signal decay of VA to AN0~AN7 pin should not be exceeding 1/4 LSB to maintain the ADC precision, and it's about 5V/4096 = 1.2mV.

1uA×RA < 1.2 mV → RA < 1.2kΩ , where 1uA is II value.
Therefore, RA is recommended to be lesser than 1.2kΩ to maintain the 10-bit ADC precision. In the similar way, for 9-bit and 8-bit ADC, RA not exceeding 2.4kΩ and 4.8kΩ respectively to maintain the conversion precision.


Question 17

What is the A/D input impedance?

Answer

When A/D is not activated, the SS (sampling switch) is open. When A/D is activated the SS is closed. The A/D conversion time can be further divided into two phases; the first is sampling time which needs 32 tAD,; the second is conversion time which needs 44 tAD. A total of 76tAD is needed. The tAD A/D clock period will be detailed in the datasheet.

Therefore we can discuss the A/D input impedance in two ways.
(1). When the sampling switch SS is open, only the current leakage effect remains, the input impedance equivalent circuit is illustrated as below;

The input impedance is about RVDD || RVSS, where RVDD and RVSS are the leakage current on the PIN. RVDD = RVSS = 5V/1uA = 5MΩ
RVDD || RVSS = 2.5MΩ

(2). When the sampling switch SS is closed, the A/D input equivalent circuit is illustrated as below; (PIN capacitance CPIN is omitted.)



The DC input impedance:
The DC input impedance is about RVDD || RVSS, where RVDD and RVSS are the leakage current on the PIN. RVDD = RVSS = 5V/1uA = 5MΩ
RVDD || RVSS = 2.5MΩ

The AC input impedance:
The time constant = (RA+RSS)×C, is shown as below;

  HT46R23, HT46R24, HT46R64, HT46R65  HT46C23, HT46C24, HT46C64, HT46C65 HT46R47, HT46R22, HT46R62 HT46C47, HT46C22, HT46C62 HT46R63 HT46C63
CS/H 225.3pF 94.2pF 112.6pF 71.3pF 56.32pF 35.6pF
RA+RSS 1.3kΩ 1.3kΩ 2.5kΩ 2.5kΩ 4.9kΩ 4.9kΩ
Time constant 0.29μs 0.12μs 0.28μs 0.18μs 0.28μs 0.17μs

Question 18

How can I find the minimum value of A/D Acquisition Time (tAC)?

Answer

To maintain the 10-bit accuracy, the voltage deviation between analog VA to sample and hold CS/H should be less than VA/2048. Therefore when SS is closed (sampling switch), the CS/H voltage must be greater than VA-VA/2048 and we can have the tAC value through the following calculations.

VA-VA/2048 < VA(1-EXP(-tAC/R×C); R=RA+RSS, C=CS/H

VA-VA/2048 < VA(1-EXP(-tAC/R×C)
→ 1/1028 > EXP(-tAC/R×C)
→ -7.625 > - tAC/R×C
→ tAC > 7.625×R×C

Per different MCU family, values are listed below:

  HT46R23, HT46R24, HT46R64, HT46R65  HT46C23, HT46C24, HT46C64, HT46C65 HT46R47, HT46R22, HT46R62 HT46C47, HT46C22, HT46C62 HT46R63 HT46C63
CS/H 225.3pF 94.2pF 112.6pF 71.3pF 56.32pF 35.6pF
RA+RSS 1.3kΩ 1.3kΩ 2.5kΩ 2.5kΩ 4.9kΩ 4.9kΩ
tAC 2.2μs 0.93μs 2.1μs 1.4μs 2.1μs 1.3μs
A/D sampling time 32tAD
32μs(min.)
32tAD
32μs(min.)
32tAD
32μs(min.)
32tAD
32μs(min.)
32tAD
32μs(min.)
32tAD
32μs(min.)

Per the table, the A/D sampling time is 32tAD, and the minimum value of tAD is 1μs, i.e. the minimum sampling time is 32μs, and it should be greater than tAC.


Question 19

What is the input voltage range of the A/D input pins?

Answer

There are protection diodes on the AN0~AN7 input pins. The input voltage is therefore should be within the range of VDD + 0.3 and VSS-0.3. Any input volt exceeds this range may result in unpredictable power consumption and/or malfunction.


Question 20

Can the I/O pins on the HT46 series of MCUs be used as LCD drive pins?

Answer

The pins on the HT46 series can be setup as either CMOS outputs or Schmitt trigger inputs, therefore they can be setup in three conditions which are, a high level output, a low level and as an input. By using an externally connected resistor divider on an I/O pin, when setup as an input, a voltage of VDD/2 can be generated. In this way a 3 common LCD configuration can be generated.


Question 21

How to use the timer auto-reload function of Holtek MCUs?

Answer

If you wish to assign the timer a start counting value that will be automatically reloaded after each timer overflow, the following steps may be taken;

  • Disable the TMRC.4 bit

  • Set the start counting value to TMR

  • Enable the TMRC.4 bit

If you wish to change the start counting value, you may simply save the new value to TMR, which will be loaded after the next timer overflow.


Question 22

For HT46 series MCUs, how to adjust the PWM frequency on port D?

Answer

For HT46 series MCUs, the PWM frequency is derived by calculating fsys/256, in other words, once the system clock is selected, the PWM frequency is therefore fixed. Users can only adjust the PWM duty through the PWM register.


Question 23

What should I do to use an external crystal during my program development?

Answer

Firstly, in selecting the Options for SYSFREQ, keep the "Internal" not checked which will let you use external clock source. Secondly, insert the crystal into Y1 position on the Interface Card, meanwhile make sure that the jumper JP1 is set to crystal. Now you can use the external crystal during your program development.


Question 24

What steps should be taken to reduce power consumption before entering the HALT mode if A/D Converter is used?

Answer

Because the A/D Converter will not turn off automatically in the HALT mode, if the power consumption is an issue, users should turn the A/D Converter off by clearing the PCR0, PCR1 and PCR2 bits in the ADCR Register before entering the HALT mode and turn the A/D Converter on by setting the PCR0, PCR1 and PCR2 bits to 1 after waking up from HALT.


Question 25

When in the low power mode, how should any unused inputs be managed? Also, what is meant by a no load condition?

Answer

Any unused I/O lines could be setup as inputs, but a pull-high resistor must be connected to these inputs, otherwise these floating inputs may consume power. Another method would be to setup any unused I/O lines as outputs and set these lines to a "0" level. A no load condition means that no connection is made to the I/Os. In this situation the only connections to the MCU are VDD, VS OSC1/OSC2 and RES.


Question 26

As the A/D converter has multiple inputs, is interference a problem.

Answer

Yes, interference may be a problem. When a conversion cycle has finished and before a different input is selected for A/D conversion, a small delay should be inserted. This will allow the input to settle down and allow a more accurate conversion. A general delay time for consideration would be a minimum of 10us.


Question 27

When using a 3-pin resonator/crystal in my MCU application can the capacitor be connected to VDD instead of VSS?

Answer

When using 3-pin resonator/crystals, for reasons of layout convenience, the capacitor can be connected to VDD instead of VSS.


Question 28

When writing my program, if I want to create a Table in Program Memory, how do I start my table at a specific address? If the ORG statement is not suitable are their other methods of implementation?

Answer

When using the ORG expression, this can only be used to indicate the offset from the start address of the present section. To overcome this problem the SECTION directive can be used to establish a table at any specific address, for example:

table .section at 300 'code'

This statement can be used to indicate the specific address where the table should begin.


Question 29

How is the A/D converter activated and how can I obtain the contents of the converted value?

Answer

Taking the HT46R22 as an example, an example for programming the A/D is shown below:
ad_convert:

clr adcr.7 ; activate A/D converter
set  adcr.7
clr  adcr.7
sz  adcr.6 ; wait for conversion to finish
jmp  $-1
mov  a,adrl ; save contents of A/D converted value
mov  adl,a
mov  a,adrh
mov  adh,a
ret

Question 30

How can the PWM function in the HT46R22 device be used to generate different voltage output levels?

Answer

Using the circuit described in the drawing below, by changing the value of the PWM registers, 256 different voltage levels can be generated.


Question 31

How can I use C language to read the serial number written into an OTP by the OTP writer?

Answer

When using the C language you must use inline assembly to read the IC serial number, which is written by the OTP writer. An example program is shown below:

First declare a variable to indicate a ram address.
unsigned long serial_num @0x80;
Then read out the serial number to this variable.

#asm

tblp equ [07h]

; define table address

mov a,20h

mov tblp,a 

; set table pointer to 20h (series number at 20h of last page)

tabrdl [80h] 

; load first byte of series number to series_num (0x80h);

inc tblp

tabrdl [81h] 

; second byte of series number

inc tblp

tabrdl [82h] 

; third byte of series number

inc tblp

tabrdl [83h] 

; fourth byte of series number

#endasm


Question 32

When using the BZ/BZB function in the HT46/HT47/HT48/HT49 series devices, the sound emitted is not loud enough, what can I do about this?

Answer

The frequency generated on the BZ/BZB outputs should match the center frequency of the piezo-buzzer connected to these pins. Each different type of piezo-buzzer has its own center frequency. The MCU generated frequency must be as close to this as possible to achieve maximum volume from the buzzer.


Question 33

After starting the TMR with a preloaded value of 240, and then immediately implementing a CLR TMR instruction, a timer interrupt seems to be generated at the wrong time and well before the overflow time should have been reached. Can you explain why this happens?

Answer

A CLR TMR instruction will not immediately clear the value of TMR to "0", but will only clear the preload register to "0". It is only when the timer overflows that the new value from the preload register will be transferred into the TMR register. The timer will start to count from a value of 240 after being started, however when the CLR TMR instruction was implemented the timer had not overflowed, therefore will not begin counting from a value of "0". As the counter will keep counting from the value of 240 it will not be long before an overflow occurs resulting in the execution of a timer interrupt.


Question 34

I have a problem using the oscillator on the HT46R64. When using the emulator everything works fine, however on the actual device, the 32768Hz oscillator will not oscillate. The problem remains even if the oscillator is replaced.

Answer

The problem may be due to the location of the oscillator being too far from the MCU device. Try to solder the oscillator directly onto the pins of the MCU and clean the contacts with alcohol after to try to eliminate this problem.


Question 35

For applications where the I/O pin connection to the application circuitry is rather long, what external protection measures should be taken?

Answer

The I/O pins have Schmitt trigger inputs, also the inputs have protection diodes between the pin and VDD and VSS. As a result the noise rejection capabilities of the devices is high, however to reduce the possibility of noise interference yet further, it is recommended that a resistor is placed in series with the I/O pin.


Question 36

How do I determine which applications should use which PWM mode, either the (6+2) mode or the (7+1) mode?

Answer

The modulation frequencies of the two types of PWM modes are not the same, therefore this should be taken into account with respect to the application. For example, for D/A applications, it would be better to use the (6+2) mode where the modulation frequency is higher and the carrier frequency easier to filter out.


Question 37

In the HT46R64 device, how do I define an LCD variable in the C language?

Answer

In the C language the variable can be directly defined in BANK0 or BANK1, therefore it is not necessary to deal with the MP1 and IAR1 registers. For example:

int v1 @ 0x40; //declare v1 in the RAM bank 0 offset 0x40 
int v2 @ 0x160; //declare v2 in the RAM bank 1 offset 0x60


Question 38

When using the HT46 emulator to emulate the HT46R23 device, if an external crystal oscillator is used and if "Internal" is not selected, when compiling the following errors are displayed:
a."power_on reset has failed" 
b."detect program counter overflow(2101h) check:(1)last instruction (2) program flow (3) Tbhp (4) bp usage"
What is the reason for this?

Answer

When this error occurs, generally the problem is because the ground connection on the 74HC04 device on the interface card has a poor connection. This can be rectified by re-soldering pin 7 on this IC.


Question 39

Why, when I write to TMRL and TMRH the contents do not change? The code I use is as follows:
mov a,131
mov tmrl,a 
mov a,0ffh 
mov tmrh,a 
When the above code is executed, the TMRL and TMRH registers retain their original value and do not change.

Answer

Before writing to TMRL and TMRH the timer interrupt must be disabled.


Question 40

When using a Holtek MCU in a voice application, within the software I wish to use look up table data as follows:
TABLE1: DC 0FFE1H,0FE32H,0FA34H,0FC78H
DC 0FECDH,0FEDCH,0FE57H,0FD87H ; 16bit table values

Is it possible for Look up table data definitions of 16-bits to accept the format of data given in TABLE1?

Answer

The Holtek MCU range each contain different Program Memory widths, ranging from 14 bits to 16 bits. MCUs that contain 16 bit Program Memory widths can accept data as shown in TABLE1 above, however other MCUs can only define data tables that are either 14 or 15-bits wide.


Question 41

When using the tools to change the value of bits in the PA port register from "0" to "1", why when after checking the content of the register, I cannot see that the PA pin has changed its value.

Answer

When changing a specific bit value on the PA data register, only bits that are setup as outputs will be changed. Bits to be changed must first be setup as outputs by writing a zero to the corresponding bit of the PAC register.


Question 42

In the HT46 A/D series of MCUs, how can I determine when the A/D conversion has finished?

Answer

There are two methods of achieving this:

  • By polling the EOCB bit in the ADCR register. Before the A/D conversion process is initiated clear the A/D interrupt enable bit. After the A/D conversion starts the EOCB bit can be polled, if the bit is high it means that the A/D conversion process is still running, when the bit changes to a low value it indicates that the A/D conversion process has finished.
  • Wait for the A/D internal interrupt to occur. Before the A/D conversion process has started, enable the A/D interrupt bit. After the A/D conversion process has started, the program can continue with running other program items. When the A/D conversion has completed, if the stack is not full, the program will automatically jump to the A/D interrupt vector where the A/D interrupt service routine can be executed. 

Question 43

In the HT46R51/52 devices, how is the PWM used? Here the PWM register address is 1AH.

Answer

First the PWM function must be enabled in the configuration options.

Then load the PWM register with the correct value and activate as shown below:

MOV A,100 ;[PWM]=100
MOV PWM,A ;
CLR PDC.0 ;PWM pin is shared with the I/O pin PD.0 - setup as an output
SET PD.0 ; activate the PWM output

The PWM function in the HT46R51/52 uses a (6+2) mode for its PWM generation. Here each PWM cycle is subdivided into 4 separate sections, with each of these sections composed of 64 system clock cycles. For the above example, where the PWM value is 100, each of these individual four sections will contain 25 system clock cycles (100/4), with the mark to space ratio of each section being 25/64.


Question 44

When using the ICE to emulate the HT46R53A, bit 7 of MP0 is always 1, therefore if 00H is written to the register then its value will be 80H. If this is the case how can the full range of the IC RAM be indirectly addressed. 

Answer

To resolve this problem, in the IDE-3000 "MP BITS"Mask Option, select 8-bits. 


Question 45

When using a Crystal system oscillator, why is it necessary to connect two resistors to the crystal?

Answer

The two resistors connected to the crystal ensure that under conditions of low supply voltage - when the power supply voltage is less than the lowest operating voltage - the oscillator is turned off. If the LVR function is enabled then these resistors are not required.


Question 46

When using the comparator function in the HT46R12A, after the comparator is enabled and a 2.8V signal input to the comparator input, the comparator input pin remains at 0V and seems like the comparator is not working?

Answer

Because all the comparator pins in the HT46R12A are shared with the pins on the PC port, therefore before using the comparator, the correct input or output condition must be first setup for the comparator to operate correctly.
Also the CMPXC comparator control register must be properly setup to ensure that the comparator is in the comparator mode and not in the calibration mode. The following programming steps help to illustrate these points:
clr cmp0c.5
clr cmp1c.5    ; select comparator mode

mov a, 0f3h
mov pcc, a    ;setup the correct comparator pins input/output condition

mov a, 3
mov ppg0c, a    ; enable the comparator
:
:


Question 47

If an MCU input pin is to be used for zero crossing detection of 110V or 220V/230V power lines, what value of external resistor should be used to ensure the device is not damaged.

Answer

When connecting an AC power line directly to an MCU input, the most important consideration is the AC line surge voltage and high frequency signals which could create excess input current or input voltage destruction. With an AC line voltage of 110V, it is recommended that a 2M ohm resistor is used. For 220V/230V AC line voltages, a recommended value of between 4 and 5M ohm is used. If the resistors are SMD types, then because their breakdown voltage is 200V, it is necessary to use 2 series connected resistors, each with 2 to 2.5M ohm value.


Question 48

What is the maximum current that can be taken by an input port?

Answer

Please do not exceed 400ua.


Question 49

On the demo board, when implementing an A/D voltage conversion, the result of the conversion is unstable and fluctuates. How can this be remedied?

Answer

Generally, the ICE emulator operates under a fixed stable operating voltage, which is normally 5V. When using the A/D on the ICE for debug purposes, it is important to note whether the A/D reference voltage is supplied by the ICE or provided externally. The A/D conversion needs a continuous clock period, therefore it is not possible to use single stepping during debug, otherwise this will lead to an inaccurate conversion value. To remove the A/D fluctuations, a filter capacitor can be added to the A/D input or use the program to obtain an average value.


Question 50

How can the accuracy of the A/D function in the Holtek microcontrollers be improved?

Answer

In general, first select a suitable system clock frequency. Because the minimum allowed A/D clock period is 1us (tad), therefore it is important to note that ADSC1 and ADSC0 can select the system clock division ratio to prevent the A/D clock from being less than 1us. When the A/D starts the conversion process or after changing the input channel, the sampling time and conversion time must be taken into account. If the time is too long or too short then an inaccurate A/D conversion result may be generated. For more details see the relevant datasheet. Additionally, it is recommended that a 104 value capacitor is added to the channel, which can improve the emulated channel sampled voltage and increase the converter accuracy.


Question 51

During the A/D converter conversion process, a certain amount of time is required for sampling and conversion. During this time can the MCU execute other instructions?

Answer

The Holtek A/D type MCU embedded successive approximation A/D converter has a conversion time dependent upon the device chosen. The reference timing unit is the A/D clock period (tAD), the actual value of which can be found in the datasheet. Because the A/D conversion is taken care of in hardware, therefore during the A/D conversion time, the MCU can continue executing other instructions. The A/D interrupt can be used to satisfy the realtime needs of the A/D converter.


Question 52

In the HT46RU25, from within ROM BANK0, how can a call to a ROM BANK1 subroutine be made?

Answer

In the HT46RU25, when in ROM BANK0, if it is required to call a subroutine from ROM BANK1, then it is first necessary to set the fifth bit of BP to 1, which makes the device then point to ROM BANK1. After this, implementing a CALL instruction should be executed. In the subroutine after executing the RET instruction, the fifth bit in BP should be cleared to 0 to enable the device to point to ROM BANK0.


Question 53

How is ROM BANK1 used in the HT46RU25?

Answer

Because the HT46RU25 ROM has a capacity of 16K, it is divided into two Banks. Each Bank has an address range of 0~1FFFH. When the ROM address is specified in BANK1, the following instructions should be used:
ROMBANK 1 CODE1
CODE1 .SECTION AT 'CODE'
ORG XXXXH
Here, XXXXH is the address to be used in BANK1


Question 54

The interrupts in the Holtek MCUs have priorities. If a high interrupt occur will it override a low priority interrupt already in progress?

Answer

When more than one interrupt occurs simultaneously, (each corresponding interrupt request flag will be set) the MCU will first respond to the highest level interrupt. However no matter which level of interrupt has occurred, after response by the MCU, its corresponding request flag will be reset and the EMI bit (master interrupt control bit) will be cleared to disable other interrupts. Therefore if the MCU has already entered a low level interrupt, it will not be disturbed by the occurrence of a higher level interrupt. Not until the present interrupt routine has finished will the other interrupt be serviced.


Question 55

Before the HT46R22 starts to transmit data, when initializing the IIC bus, are there any special points to note?

Answer

The following points should be noted:
1. Write the slave address into the IIC bus address register HADR
2. Set the HEN bit high in the IIC bus control register, HCR to enable the IIC bus
3. Set the EHI bit high in the Interrupt Control Register INTC1 to enable the IIC bus interrupt


Question 56

As the HT46R22 is a slave device, when implementing IIC communication, how is control of SDA relinquished?

Answer

The slave device relinquishes control of SDA in order to receive signals transmitted from the host. The method of relinquishing SDA control is as follows:
1: CLR HTX
CLR TXAK
2: virtually read HDR
for example: MOV A, HDR
After executing the first step above, the slave device will be setup in a receive mode. Executing the second step will reset the related bits in the status register HSR such as the HAAS and the HCF bits.



Points to Note

 


Question 1

In the HT46X22 series of devices when a "0" is written to bit 7 of the memory pointer MP, when it is read out, why does it give a value of "1"?

Answer

The HT47X22 Data RAM address is located at the address range 40H~7FH. Because the data RAM capacity does not exceed 80H, a 7-bit memory pointer (Bit0~Bit6) is adequate. Reading bit 7 of MP will always give a value of "1" irrespective of what value has been written into it. If the value "70H" is written to MP it will be read back as "F0H" but in fact the actual address pointed to is "70H" which is correct for the indirect addressing operations.


Question 2

When in HALT mode why does the device continue to consume power?

Answer

When the MCU enters the HALT mode the oscillator is stopped. However if the WDT oscillator (if WDT is enabled in the options) or if the RTC oscillator is still running then some power will be consumed. In addition, the I/Os will maintain the condition they were in when the HALT instruction was executed. It is important to check if the I/Os inputs are floating or outputs remain loaded in the HALT mode that they might consume power.


Question 3

When using the HT-ICE to emulate the A/D conversion process, are there any special consideration that should be taken into account?

Answer

When the HT-ICE emulates the A/D process, the analog signal to be converted can be directly connected to the pins AN0-AN7 on the ICE. However the analog voltage must not exceed 5V otherwise the ICE may be damaged. When using the HT-ICE to emulate the A/D it is also important to ensure that jumper JP2 is in the correct position as shown below:

JP2 at position 1-2 will utilize the ICE internal 5V as the voltage reference
JP2 at position 2-3 will utilize an external reference voltage at JP3/JP4


Question 4

When directly connecting the application circuit board to the A/D part of the HT-ICE are there any special considerations that should be taken?

Answer

When the HT-ICE and the target board are connected together it is important to remember that the power supply for the HT-ICE and the target board will be different. If the target board circuit uses an AC power supply adapter then an isolating transformer should be used.


Question 5

What are the OTP dice programming steps for COB form?

Answer

  • Bond the dice to the COB

  • Program the dice on the COB

  • Conduct a COB functional test

  • Encapsulate the COB and afterwards solder the other devices


Question 6

I want to produce my products with an OTP dice form on board, how do I program those OTP dice devices?

Answer

To program OTP devices, 11 pins are required and they should be reserved on the PCB. Please check your local agent for detailed information of those pins. Users should prepare the connecting cable from those 11 pins to the 40-pin TEXTOOL on the programmer and then follow the standard programming procedure to burn the device on the PCB. Note that the tracks of those 11 pins on the PCB should be as short as possible and among them the PA0~PA6 should avoid connections to the outputs of other devices. If this situation cannot be avoided, a 1K ohm resistor in series with each line is recommended. In addition, the cable from the PCB to the programmer should be less than 15 cm.


Question 7

What could be the reasons for low yield programming of OTP DICE devices?

Answer

Firstly, you should exclude bonding failure possibilities, as these are the major reasons for poor programming yield. If you are not sure whether there is a bonding issue, you may get assistance from our technical support personnel by sending us the decapsulated samples.


Question 8

When I use the HT-Writer to program the OTP Dice, an "MCU: Cannot identify" message will pop up. Is this a bonding problem or an OTP defect?

Answer

For the package form of OTP devices, its product ID will be burnt into the device which can be used to display the device information in the message window, however, if the product ID code is missing, a warning message will pop up. This is usually the case for dice form OTP devices which have no product ID. To disable this warning function, deselect the Check ID option under the Options menu. If the HT-Writer is to be used in stand-alone mode, set the switch DIP1, which is located on the back of the HT-Writer to the OFF position.


Question 9

What precautions should I take in designing the MCU Reset and Oscillator circuit?

Answer

Please refer to the "HA0075E" in the Application Notes section of our company web site.


Question 10

Is the substrate on the HT46R64 device connected to VSS or VDD?

Answer

The Holtek MCUs use a Poly Gate process, therefore the substrate is connected to VSS.


Question 11

How can I manage unused areas of program memory?

Answer

In order to preserve program reliability, and prevent erroneous operation due to false jumps, it is recommended that unused area of program memory are written with a "JMP 00H" instruction. This has a machine code of 2800H. If this is done, should the program jump to an unused area of program memory, the program will return to the start address, which should ensure the prevention of erroneous operation.


Question 12

After compiling, how can I determine the amount of program memory area used by my program?

Answer

The .map file can be opened to see the ROM conditions. The .map file and the .prj file are in the same folder. If the file cannot be found, then before program compilation, under the Option Menu Command, select Project and ensure that the "Generate Map File" option has been selected. When the next compilation is executed the .map file will be generated.


Question 13

If I want to use the timer to wake up the system when in the HALT mode, I encounter the following problem. The Holtek datasheet says that after the HALT instruction is executed the system clock will be stopped, if this happens how can the timer be used to wake up the system?

Answer

When in the HALT condition, the system clock is stopped, so if the timer source clock originates from the system clock, the timer will also cease its counting function when the system enters the HALT mode. However if the timer clock source originates from another clock source such as the RTC, the timer will continue to function even when in the HALT mode. In this case when a counter overflow occurs, the system will be woken up if it is in the HALT mode.


Question 14

In the HT46 series, when the tools are in the software simulation mode and not the emulation mode, is it possible to still simulate the internal analog to digital converter?

Answer

It is not possible to simulate the action of the A/D converter if in the software simulation mode. The A/D converter can only be simulated by the ICE hardware and therefore the tools must be in the emulation mode.


Question 15

Is it possible to use the IIC interface on the HT46R22 to read and write data to an HT24 EEPROM?

Answer

The IIC interface on the HT46R22 can only operate in a slave mode, it is not possible for it to operate in a master mode to read and write data to an external EEPROM. If it is required to read and write data to an external EEPROM then the I/O lines can be used to emulate an IIC interface function.


Question 16

What are the EEPROM requirements for the HT46R49E?

Answer

When controlling the EEPROM it is important to take note of the EEPROM timing requirements. This is especially true for higher system clock speeds where for high frequency conditions the read and write functions may operate abnormally. For actual values consult the EEPROM A.C. Characteristics.


Question 17

When using the IDE3000 to emulate the HT46R52A, why is the 7th bit of the MP0 register always 1?

Answer

In the IDE3000, the configuration options for the HT46R52A, can select the MP bits to be either 7-bits or 8-bits. When the MP is selected to be 7-bits, the 7th bit of MP0 will always be 1. If it is required to control the 7th bit of MP0 then the Configuration Option must select the MP bits to be 8-bits.


Question 18

The table is constructed within the Program Memory and also the program statements are contained in the Program Memory. However during assembly the following error message is generated: Program code is too large! What is the reason for this?

Answer

The “MOV A, OFFSET TAB_Address+Num”statement must be used in the correct way. For example if TAB_Address is first address of a table established in the Program Memory, if the table is wholly contained within the Program Memory, and if the TAB_Address+Num(Num is the programmer defined address deviation)indicated address exceed the Program Memory space, then the error mentioned will occur.
This is easy to ignore, therefore care is needed when using the “MOV A, OFFSET TAB_Address+Num”instruction. It is recommended that the following two instructions are used:
MOV A, OFFSET TAB_Address
ADD A, Num

。。。(the ADD is for overflow locating and related handling)
If used then this will prevent this error, because to determine if the table address TAB_Address is within the Program Memory is easy to discover.


Question 19

For the PCR bits (0~2) in the ADCR register for the HT46 series devices, which are used to setup the A/D channels, when simulating the inputs only one line, PB2, is an input. When PB0 and PB1 are used as normal I/O pins, when the A/D function is used will pins PB0 and PB1 be influenced?

Answer

They will be influenced. Because when PB2 is used as an A/D input (PCR (0~2) are setup as shown in the accompanying figure), at the same time PB0 and PB1 will also be setup as A/D converter inputs and will no longer have normal I/O functions. For example if PBx (x=0~7) are used for simulated inputs, it is recommended that the lowest bits on PB are first used. For example, first select PB0 to be the A/D input, then select PB1 and PB2 to be I/O pins.



Others

 


Question 1

Are the HT46 A/D type MCUs available in Dice form?

Answer

Holtek provides a service to supply customers with high volume requirements for Dice Form MCUs. Available for the full range of devices it is important that customers take note of the special requirements of dice form devices for bonding and OTP programming.


Question 2

What are the ESD and Latch up features of the HT46 A/D type MCUs?

Answer

As the HT46 A/D type series of MCUs possess exceptional ESD and Latch up protection they are suitable for industrial use. In the area of ESD protection the devices conform to the US military spec MIL-STD-883E 3015.7 and each I/O can withstand in excess of 5KV of body static. Regarding latch-up, the devices conform to the JEDEC-NO.17 specification, when tested in current mode, each I/O can withstand in excess of 100mA.


Question 3

What is the duration of the Power On Reset?

Answer

For the HT46 A/D Type MCUs at 3V operating voltage, the Power On Reset time range is 45ms~180ms;at 5V, the Power On Reset time range is 35ms~140ms.


Question 4

What is the constraints on VDD during Power On?

Answer

To ensure the Power On Reset operates successfully, the VDD rising voltage is recommended to be completed within 20ms. For battery applications, the internal resistance will increase due to the low battery condition and will slow the rising edge of the power supply increasing the possibility of Power On Reset failures.


Question 5

Are the Reset circuits provided in the data sheets suitable for all applications?

Answer

Usually, the Reset circuits provided in the data sheets are applicable for most applications. Under some circumstances, a noisy environment for example, the Reset circuit might need to be modified for special user considerations.


Question 6

In the HALT mode, is there any power consumption associated with the Low Voltage Reset (LVR) circuitry?

Answer

In the HALT mode, the Low Voltage Reset function has no effect, therefore, there is no power consumption considerations when in the HALT mode.


Question 7

When an RC type clock is chosen as the system clock, how can the actual frequency obtained from this RC clock be measured?

Answer

When the RC clock is chosen as the system oscillator, pin OSC2 will be configured as a frequency measurement output pin, which can be used to measure the actual frequency that is generated by the RC oscillator. This pin is designed to provide a signal that is equal to the system oscillator frequency divided by four. However it should be noted that because the OSC2 output is an open drain NMOS output structure, it is necessary to connect a resistor between this line and VDD.


Question 8

When using the MACRO assembly directive can I save Program Memory space? Also does it affect the MCU execution speed?

Answer

After the assembly process, all of the instructions belonging to the MACRO will be written into Program Memory area, therefore there is no influence on either the Program Memory space or on the speed of execution. However as the code has been simplified program maintenance will be easier.


Question 9

If the crystal metallic casing is connected to ground, will it improve the noise immunity and the oscillation frequency accuracy?

Answer

Actually the main reason for connecting the casing to ground is mainly for structural reasons to prevent movement of the crystal. The circuit board layout should take care of the EMI issues. Only where very high frequencies are involved, should the issues of EMI, which could be caused by overshoot be taken into account. For most purposes the issues of noise immunity can be taken care of by good circuit board layout.