EMC MCU learning four

Some things worth noting when using ELAN microcontroller:
1. The stack is 5 levels. If you use more than 5 levels of subroutine calls, when calling the subroutine to execute the CALL instruction, first put PC+1 on the stack, and then Reprint the low ten-bit value of R2; the RET instruction loads the top data of the stack into the PC. After actual test, when using six-level subroutine call, you can enter all levels of subroutines, but when returning, 5, 4, 3, 2, 1 can all return to the previous level subroutine, but the 0-level subroutine cannot It returns to the main program correctly, but keeps looping between returning and calling the next instruction of the first-level subroutine instruction, and cannot return to subroutine
2 correctly . The P63 pin in EM78P153 cannot be used as output.
3. The return of the RET subroutine and the return of the RETI interrupt.
4. If the unused I/O Pin is floating, it will cause the power consumption of the IC. The best way to deal with it is to set the unused I/O Pin to Output Pin.
5. One ROM page can write 1K instructions
per page, which is 1024 lines of instructions . 6. Instruction time: when CLKS is selected as 0, execute a single-cycle instruction time: 2/system frequency; when CLKS is selected as 1, execute a single-cycle instruction Time: 4/system frequency
7, RAM will be cleared after power-on, this needs to be determined according to the data manual, which cannot be taken for granted. Since the data in the RAM is in an uncertain state after power-on, it will affect the operation or condition judgment of the microcontroller, so it must be cleared.
8. Use TCC as the clock. If the clock is 32.768KHZ, the prescaler is 1: 256, then one second to be interrupted several times how to calculate??
If Option select 2 clocks, 32768 / 2clks = 16384 Hz (1/16384) * 256 = 0.015625 Miao
namely TCC (R1) will be every 0.015625 seconds plus 1
- -1 second / 0.015625 second = 64
---That is, when TCC (R1) increases by 64, one second has passed. If you want to interrupt once per second, you must first move TCC(R1) into 256-64=192,-so
TCC will overflow every time it counts 64, and TCC overflow will generate an interrupt. Strictly speaking, this is not really one second. During interrupt processing, instruction execution also takes time. These times must be included, otherwise the error will become larger and larger.
9, Sleep Mode Sleep,
initialization MOV PORT6, PORT6; PORT6 status change interrupt is preparing
to call before SLEEP
MOV A, @ 0B00001111; Prescaler assigned to the WDT
CONTW
WDTC
MOV A, @ 0b00000000; prohibit WDT
IOW WDTCR
MOV PORT6 ,PORT6; read the status of PORT6
DISI
MOV A,@0B00000011; enable external pin interrupt
IOW IMR
;——————–
SLEP will enter sleep mode when calling sleep;
;——————-
; wake up from here Execute
WDTC
NOP
MOV A,@0B00000000 after the sentence; prohibit WDT
IOW WDTCR
nop
mov a,@0b00000001
iow iocf
MOV A,@0B00000100
CONTW
; Jump to the main program

10. There are three subtraction instructions for EMC, as follows:
SUB A,R (RA→A)
SUB R,A (RA→R)
SUB A,K (KA→A) It
should be noted that the position of A is either in the front or Later, A is a subtraction, not a subtract.
In EMC's instruction system, when a borrow occurs in the subtraction, CY=0, and CY=1 when a borrow does not occur.

Guess you like

Origin blog.csdn.net/u013830926/article/details/69253763