Usage design of program skip PAGE in EM78 series MCU

5.1.1. Table lookup instructions and usage

The EM78 series of eight-bit micro-controllers use the three steps of (1) "call", (2) change PC (or "tbl"), (3) "retl k" to look up the table. Where "retl k" is the value of the constant k passed to the working register "A".

In step (2), if you change the PC with "mov 0x2, a", or "add 0x2, a", etc., because these instructions will clear bits 8, 9 of PC (R2) (only clear in EM78056) Bit 8), so the contents of the lookup table can only be placed in the lower 256 addresses of each PAGE of the program. If the "tbl" instruction is used to change the PC in step (2), this instruction will not clear bits 8, 9 of PC (R2), but retain bits 8 and 9 of the address where "tbl" is located, so look up the table. The content can be placed anywhere in the PAGE of the program.

Usage design of program jump PAGE in EM78 series MCU

Example: check the table

Table add 0x02,a ;Change the PC by adding the relative position to the PC

Retl @0x19 ; return constant content 19h to "A"

Retl @0x74 ; return constant content 74h to "A"

Retl @0x2e ; return constant content 2eh to "A"

Retl @0x54 ; return constant content 54h to "A"

Retl @0x4b ; return constant content 4bh to "A"

Inc 0x18

Mov a, 0x18 ; the relative position of the content to be checked is placed in "A"

Call table

Mov 0x10, a ; look up the contents of the table and move to R10

5.1.2. Usage of PAGE

1. The usage of program skip PAGE:

The EM78 Series Octal Microcontroller divides its Program Memory (ROM) into several PAGEs, each of which is 1K in length (except EM78056). Bit 5 (6) of the R3 register is the “PAGE select bit”. When the “jmp” or “call” instruction is executed, the “PAGE select bit” is loaded into the Program Counter bit 10 (11), so when the program exceeds 1K When the "jmp" or "call" instruction is executed (EM78056 is 0.5K), it is very important to set the "PAGE selection bit" correctly. The following uses EM78256 as an example to illustrate the method of skipping PAGE.

example

Example: Jump from PAGE 1 to PAGE 0

; PAGE 0, begin at 000h

049 add 0x11,a

050 mov a, @0x55

051 mov 0x05,a ;port5"-- 0x55

052 bs 0x03,5 ;select PAGE 1

053 jmp lab1 ;PAGE jump

054

; PAGE 1, begin at 400h

447

448 mov a, @0x3f

449 xor 0x12,a

450 Lab1 bc 0x06,3

451 mov a, 0x05

Description:

052: Set bit 5 of the R3 register to "1" (select PAGE 1).

053: Lab1 will be compiled to "50" and the program will jump to the address of "Lab1" (450) in PAGE 1.

note:

In this case, "052" and "053" are used to skip PAGE. If there is no "052" line command, the program will jump to the address of "050" (in PAGE 0), so it will not meet expectations. the goal of.

2. Different PAGE subroutine calls:

As described in item 1, when the program exceeds 1K, the setting of "PAGE select bit" must be considered when executing the "call" instruction. The following uses EM78256 as an example to illustrate how to call different PAGE subroutines.

Example: Calling a subroutine in PAGE 1 from PAGE 0

; PAGE 0, begin at 000h

049 add 0x11,a

050 mov a, @0x55

051 mov 0x05,a ;port5"-- 0x55

052 bs 0x03,5 ;select PAGE 1

053 call Lab2 ;PAGE jump

054 bc 0x03,5 ;restore

055 jbs 0x15, 2

056

; PAGE 1, begin at 400h

417

418 mov a, @0x3f

419 xor 0x12,a

450 Lab2 bc 0x06,3

451 mov a, 0x05

45f ret

Description:

052: Set bit 5 of the R3 register to "1" (select PAGE 1).

053: Lab2 will be compiled to "50" and call the "Lab2" subroutine in PAGE 1.

054: Restore bit 5 of the R3 register to "0".

note:

In this example, "052" and "053" are the subroutines used to call "Lab2" in PAGE 1, and if there is no "052" command, the program will call the address of "050" (in PAGE 0). Instead of the address of "450" ​​(in PAGE 1), an error will occur.

5.1.3. The effect of "BS", "BC" and other instructions on the I/O Port:

“BS”, “BC” and other commands will have “read” and then “write” actions. For example, “bc 0x06, 3” will read the entire Port 6 (8 PIN) into the CPU, and then execute the bit operation and then write to On Port 6. If Port 6 has some pins that are bidirectional I/O pins (such as P65), suppose that when Pc is the input pin when “bc 0x06, 3” is executed, the contents of P65 pin will be read and written to Latch, overwriting. The content on the original Latch. So as long as P65 is always the input pin, there will be no problem. Once P65 is switched to output, the content on Latch will be unpredictable.

5.1.4. Path read by I/O Port:

If you carefully study the I/O Port structure of the EM78 series of eight-bit microcontrollers, you can find that when you do "read" the I/O Port (such as "mov a, 0x06"), there are two paths to read. Source, one is the content on the I/O pin, the other is to output the content on the Latch, and the I/O control register determines the path to be read.

For example, when the I/O pin is designed as an input pin (the corresponding I/O control register is "1"), when the I/O Port is "read", the contents of the pin are read. If the I/O pin is designed as an output pin (the corresponding I/O control register is "0"), when the I/O Port is "read", the contents of the output Latch are read.

5.1.5. Use of WDT (Watchdog TImer):

The WDT is a timer for the internal RC self-oscillation of the microcontroller. The basic period of the timeout overflow (TIme-out) is about 18ms. The WDT has a doubler shared with the TCC, which makes the timeout overflow (TIme-out). The maximum period can be up to about 2.2 sec. The enable or disable of WDT timing is controllable at any time (control bits are in the IOCE register). When the WDT is enabled, its timeout overflow will cause the microcontroller to RESET (or wake up), the "wdtc" instruction is used to clear the WDT, and the WDT is timed from the beginning, so the appropriate "wdtc" instruction can be used. Make STOP not happen to WDT. When the WDT is disabled, the WDT does not cause the microcontroller to RESET or wake up. It is important to note that the WDT is enabled after Power-on. If the WDT is not used in this application, the WDT timing must be disabled at the beginning of the program. The EM78156/256/456 is designed as described above.

In addition to the above design, EM78247/447/248/448/056/P156 has a Code OpTIon decision to enable or disable the WDT. Its function is as follows:

1. If the WDT is used in the application, the WDT must be enabled with the Code Option. The WDT can be enabled or disabled at any time in the program. Note: The WDT is enabled after Power-on.

2. If the WDT is not used in the application, the WDT can be disabled by the Code Option, then the WDT is forbidden forever. This eliminates the need to disable the WDT timing with instructions at the beginning of the program.

5.2. Basic design rules

5.2.1. Setting the mode of the I/O port:

The user can individually set any of the I/O pins to the output mode (Input Mode) or the input mode (Input Mode). As long as each I/O setting is written to the accumulator (A) and the contents of the accumulator are written to the I/O control register, the setting is completed.

Example 1: Set PORT6 to OUTPUT PORT.

Braided Split Loom

Braided Wrap Around Sleeving,Braided Split Loom For Cable Harness Protection

1. Braided Wrap Around Sleeving offers innovative solutions for the protection of breakout areas

and provides easy removal when is necessary an inspection or maintenance of cables.

2. The special open structure allows to be installed after other components, for example copper terminals and connectors.

3. A strong resilience protects wires and cables and meanwhile provides exceptional abrasion and flame resistance.

PET Wrap provides the same flexibility and abrasion resistance as the PET Expandable Braided Sleeving but with the added feature of a hook and loop closure running the length of the material.

This allows you to work on segments of the cabling, rather than having to remove the entire covering and re-run all of its contents.



Cable Loom Wrap,Black Cable Sleeve ,Corrugated Tube Split Loom,Braided Wire Loom For Wire

Shenzhen Huiyunhai Tech.Co.,Ltd , https://www.hyhbraidedsleeve.com