Difference between revisions of "83Plus:Ports:14"

From WikiTI
Jump to: navigation, search
m
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Category:83Plus:Ports:By_Address:Protected|14 - Flash Control]] [[Category:83Plus:Ports:By_Address|14 - Flash Control]] [[Category:83Plus:Ports:By_Name|Flash Control]]
 
[[Category:83Plus:Ports:By_Address:Protected|14 - Flash Control]] [[Category:83Plus:Ports:By_Address|14 - Flash Control]] [[Category:83Plus:Ports:By_Name|Flash Control]]
 +
{{Protected Port}}
 +
 
== Synopsis ==
 
== Synopsis ==
 
'''Port Number:''' 14h
 
'''Port Number:''' 14h
Line 5: Line 7:
 
'''Function:''' Flash Write-Lock Control
 
'''Function:''' Flash Write-Lock Control
  
This port controls whether or not the Flash ROM chip will accept write/erase instructions.
+
Writing to this port controls whether or not the Flash ROM chip will accept write/erase instructions. However, writes are only accepted after the [[:Category:83Plus:Ports:By Address:Protected|unlock sequence]] is executed from a protected page.
  
 
=== Read Values ===
 
=== Read Values ===
* '''83+ Basic only''': Reads absolutely nothing of any significance.
+
* '''83+ Basic only''': Mirror of [[83Plus:Ports:04|port 04h]].
* '''83+ SE/84+ only''': Reads 0 if the flash is locked, 1 if the flash is unlocked.
+
* '''83+ SE/84+ only''': Reads 0 zero.
  
 
=== Write Values ===
 
=== Write Values ===
* Write 00h to lock the flash. Write 01h to unlock it, but note that writes to this port are only accepted from privileged ROM pages. See Comments for what the privileged pages are.
+
* Write 00h to lock the flash. Write 01h to unlock it.
  
 
== Comments ==
 
== Comments ==
 
When the flash chip is locked, then write/erase instructions are rejected. In addition, protected pages cannot be read. There is only one protected page. On the normal 83+, this is page 1Eh. On the normal 84+, it is 3Eh. On the 83+ SE and 84+ SE it is 7Eh. This page holds the certification data, which includes ID number, validation number, application authorizations, public keys, and other related data.
 
When the flash chip is locked, then write/erase instructions are rejected. In addition, protected pages cannot be read. There is only one protected page. On the normal 83+, this is page 1Eh. On the normal 84+, it is 3Eh. On the 83+ SE and 84+ SE it is 7Eh. This page holds the certification data, which includes ID number, validation number, application authorizations, public keys, and other related data.
  
The flash can only be locked and unlocked from privileged ROM pages. The privileged ROM pages are two utility code pages and one or two boot code pages. On the normal 83+ the pages are 1Ch, 1Dh, and 1Fh. On the normal 84+ the pages are 3Ch, 3Dh, and 3Fh. On the 83+ SE the pages are 7Ch, 7Dh, and 7Fh.  On the 84+ the pages are 6Fh, 7Ch, 7Dh, and 7Fh.
+
Use bit 2 of [[83Plus:Ports:02|port 2]] to check if flash is unlocked.
 
+
Finally a specific sequence of instructions must be executed (all of them from a privileged page, with no interruptions) before the port will finally listen. The sequence is:
+
 
+
<nowiki>nop
+
nop
+
im 1
+
di</nowiki>
+
 
+
''Note: it is still unclear whether all or only part of this sequence is actually required. But since TI uses this exact sequence every time, it is best to play it safe and use the exact sequence.''
+
 
+
After this sequence, use out (14h), a to write the port.
+
 
+
Note that as a side effect, interrupts are disabled, and standard interrupt handling (mode 1) is selected. To ensure this sequence runs uninterrupted, however, you should use di prior to executing this sequence. If an interrupt fired in the middle of it, it would mess up the whole thing. Also, the A register must be previously set to the correct value (0 to lock, 1 to unlock).
+
 
+
''Side note: TI also adds an additional di after the write. Sources inform me, however, that this is not required.''
+
 
+
== Example ==
+
<nowiki>ld a, 1 ;Unlock
+
di ;Make sure we don't get interrupted.
+
nop
+
nop
+
im 1
+
di
+
out (14h), a
+
  
xor a ;Lock.
+
Other protected ports may be written to from any area (unprivileged ROM, RAM, etc) without requiring a special sequence once Flash is unlocked.
di
+
nop
+
nop
+
im 1
+
di
+
out (14h), a</nowiki>
+

Latest revision as of 14:40, 11 May 2014

This port is protected, which means user programs cannot ordinarily write to it directly.

Synopsis

Port Number: 14h

Function: Flash Write-Lock Control

Writing to this port controls whether or not the Flash ROM chip will accept write/erase instructions. However, writes are only accepted after the unlock sequence is executed from a protected page.

Read Values

  • 83+ Basic only: Mirror of port 04h.
  • 83+ SE/84+ only: Reads 0 zero.

Write Values

  • Write 00h to lock the flash. Write 01h to unlock it.

Comments

When the flash chip is locked, then write/erase instructions are rejected. In addition, protected pages cannot be read. There is only one protected page. On the normal 83+, this is page 1Eh. On the normal 84+, it is 3Eh. On the 83+ SE and 84+ SE it is 7Eh. This page holds the certification data, which includes ID number, validation number, application authorizations, public keys, and other related data.

Use bit 2 of port 2 to check if flash is unlocked.

Other protected ports may be written to from any area (unprivileged ROM, RAM, etc) without requiring a special sequence once Flash is unlocked.