Application Note
AN1060 — Rev. 1.0
MOTOROLA
251
95 ****************************************************
96 * PROGRAM - Utility subroutine to program EPROM.
97 * Prior to calling PROGRAM set baud rate, turn on SCI
98 * set X=2ms prog delay constant, and set Y=first
99 * address to program. SP must point to RAM.
100 * Bootloader leaves baud set, SCI enabled, X=4200
101 * and Y pointing at EPROM start ($D000) so these
102 * default values don't have to be changed typically.
103 * Delay constant in X should be equivalent to 2 ms
104 * at 2.1 MHz X=4200; at 1 MHz X=2000.
105 * An external voltage source is required for EPROM
106 * programming.
107 * This routine uses 2 bytes of stack space
108 * Routine does not return. Reset to exit.
109 ****************************************************
110 BF13 PRGROUT EQU *
111 BF13 3C PSHX Save program delay constant
112 BF14 CE1000 LDX #$1000 Point to internal registers
113 BF17
114 * Send $FF to indicate ready for program data
115
116 BF17 1F2E80FC BRCLR SCSR,X $80 * Wait for TDRE
117 BF1B 86FF LDAA #$FF
118 BF1D A72F STAA SCDAT,X
119
120 BF1F WAIT1 EQU *
121 BF1F 1F2E20FC BRCLR SCSR,X $20 * Wait for RDRF
122 BF23 E62F LDAB SCDAT,X Get received byte
123 BF25 18E100 CMPB $0,Y See if already programmed
124 BF28 271D BEQ DONEIT If so, skip prog cycle
125 BF2A 8620 LDAA #ELAT Put EPROM in prog mode
126 BF2C A73B STAA PPROG,X
127 BF2E 18E700 STAB 0,Y Write the data
128 BF31 8621 LDAA #ELAT+EPGM
129 BF33 A73B STAA PPROG,X Turn on prog voltage
130 BF35 32 PULA Pull delay constant
131 BF36 33 PULB into D-reg
132 BF37 37 PSHB But also keep delay
133 BF38 36 PSHA keep delay on stack
134 BF39 E30E ADDD TCNT,X Delay const + present TCNT
135 BF3B ED16 STD TOC1,X Schedule OC1 (2ms delay)
136 BF3D 8680 LDAA #OC1F
137 BF3F A723 STAA TFLG1,X Clear any previous flag
138
139 BF41 1F2380FC BRCLR TFLG1,X OC1F * Wait for delay to expire
140 BF45 6F3B CLR PPROG,X Turn off prog voltage
141 *
142 BF47 DONEIT EQU *
143 BF47 1F2E80FC BRCLR SCSR,X $80 * Wait for TDRE
144 BF4B 18A600 LDAA $0,Y Read from EPROM and...
145 BF4E A72F STAA SCDAT,X Xmit for verify
146 BF50 1808 INY Point at next location
147 BF52 20CB BRA WAIT1 Back to top for next
148 * Loops indefinitely as long as more data sent.
149
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.