Points to note when programming ELAN MCU

Source: Date: 2020-11-25

1. When the program is more than 1K, there will be page skipping. If there is an interrupt handler at this time, after entering the interrupt, you must reset the PS0 and PS1 bits of STATUS to 0 (that is, return to page 0 ROM) , Otherwise the program will go wrong when it encounters jump instructions such as JMP or CALL!

2. When the program is more than 1K and the jump instruction BS STATUS PS0 or BS STATUS, PS1 is used, it will affect the interruption time of the interrupt program, and the period division factor is not expected (that is, TCON is affected); and the interrupt is automatically closed. After the jump returns, the interrupt (such as ENI) must be reopened.

3. Pay attention to the nesting level of the subroutine. Generally, the X-level stack allowed by hardware is subtracted by at least one interrupt program, that is, subroutines are better to use X-1 nesting; otherwise, errors will occur.

4. Any instructions that directly modify R2 (ie PC), such as: ADD R2, A | MOV R2, A | BC R2, x, etc. will clear the 9th and 10th bits of the PC. Jumps are limited to the first 256 addresses of a program. Except for the TBL instruction, it will not change the 9 and 10 bits of the PC; execute TBL==PC+1+A; it can solve the consequences of directly modifying R2 (that is, PC) before. The general look-up subroutine is placed at the forefront of the program to avoid clearing the 9 and 10 bits.

5. The high level of an eight-bit microcontroller is generally 4.5~5V, and the low level is generally below 1V; how to make the microcontroller generate a 2.5V voltage? You can set the I/O port that needs to output 2.5V level to output state and set it to high level; then set the output port to input state, then a 2.5V level voltage will be output.

6. Since a Chinese is two bytes, you should be careful when commenting to avoid half of the Chinese characters in the program comments; once such a problem occurs, it can cause compilation errors or abnormal functions.

To

Development strength

Professional and experienced software and hardware

Global channels

Provide customers with cost-effective products and services

Quality Assurance

The professional test guarantee team guarantees the stability

After-sales service

Professional technical service team, 24 hours to provide customers