IP2022 Data Sheet www.ubicom.com 47 4.7 Self-Programming Instructions The  IP2022  has  several  instructions  used  to  read  and
write the program RAM and the program flash memory.
These instructions allow the program flash memory to be
read and written through special-purpose registers in the
data memory space, which allows the flash memory to be
used to store both program code and data.
Because no special programming voltage is required to
write  to  the  flash  memory,  any  application  may  take
advantage of this feature at run-time. Typical uses include
saving phone numbers and passwords, downloading new
or updated software, and logging infrequent events such
as errors and Watchdog Timer overflow.
The self-programming instructions are not affected by the
code-protection flag (the CP bit of the FUSE1 register), so
the  entire  program  memory  is  readable  and  writable  to
any software running on the IP2022.
There are five instructions used for self-programming, as
shown in Table 4-8. Certain uses of the instructions are
not valid. In these cases, the instruction is executed as
though it were a nop instruction (i.e. the program counter
is incremented, but no other registers or bits are affected).
Table 4-6  Program Control Instructions Assembler Syntax Description Cycles Opcode    Flags
Affected
call addr13 Call subroutine 3 110k kkkk kkkk kkkk None jmp addr13 Jump 3 111k kkkk kkkk kkkk None int Software interrupt 3 0000 0000 0000 0110 None nop No operation 1 0000 0000 0000 0000 None ret Return from subroutine 3 0000 0000 0000 0111 PA2:0 reti #lit3 Return from interrupt 3 0000 0000 0000 1nnn All retw #lit8 Return from subroutine with literal into W 3 0111 1000 kkkk kkkk PA2:0 Table 4-7  System Control Instructions Assembler Syntax Description Cycles Opcode    Flags
Affected
break Software breakpoint 1 0000 0000 0000 0001 None ferase Erase flash block 1 0000 0000 0000 0011 None fread Read from flash memory 1 0000 0000 0001 1011 None fwrite Write into flash memory 1 0000 0000 0001 1010 None iread Read from external/program memory 4 0000 0000 0001 1001 None ireadi Read from external/program memory and
increment
4 0000 0000 0001 1101 None iwrite Write into external memory/program RAM 4 0000 0000 0001 1000 None iwritei Write into external memory/program RAM
and increment
4 0000 0000 0001 1100 None loadh addr8 Load high data address into DPH 1 0111 0000 kkkk kkkk None loadl addr8 Load low data address into DPL 1 0111 0001 kkkk kkkk None page addr3 Load page bits from program address 1 0000 0000 0001 0nnn PA2:0 speed #lit8 Change CPU speed from literal 1 0000 0001 nnnn nnnn None