Myke's Home Page
|
"Short" ExperimentThis is the shortest useable application that I could come up with. The application resides at the end of program memory and flashes an LED connected to RB7. The application itself could be coded as:
LIST R=DEC
include "p16f84.inc"
org 0x03FE
tris PORTB ; Save "w" in TRISB
xorwf PORTB, f ; XOR PORTB with the contents of "w"
end
This application is designed to be loaded into a 1,024 instruction EPROM OTP PICmicro® microcontroller to allow it to be tested in circuit (to make sure it can run) before the final application is programmed in. The actual application is much more complex because of the need for it to potentially execute in the YAP-II, which cannot move the internal program counter more than fifty addresses for each line of the application's hex file.
The experiment uses the circuit shown below.
The parts needed for this experiment are listed in the table:
Using a breadboard, the experiment is wired using the guide:
If the YAP-II is used, the experiment is wired as:
The source code listed below can be accessed from the CD-ROM by clicking Here. The "YAPProg" #define is used to specify additional lines (which are not programmed) to keep the PICmicro MCU's internal Program Counter accurate through the programming operation.
title "SHORT - Is this the Shortest Possible Application?"
#define nYAPProg
;
; Look at a Two Instruction Application. Continually Update
; w (with the "unprogrammed" ADD 0x0FF) and then use the
; value for "PORTB" and "TRISB".
;
; Hardware Notes:
; 16F84 Running at 4 MHz
; Reset is tied directly to Vcc and PWRT is Enabled.
; PortB is used for Output
;
;
; Myke Predko
;
; 99.10.26 - "Short" Created
;
list R=DEC
include "p16f84.inc"
__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF
ifndef YAPProg
org 0x03FE ; Start Application at Program End
else
org 0x0 ; Load Instructions to Program Memory
; End so there isn't a large "jump"
variable i = 0 ; in instructions the YAP can't handle
while (i < 0x0100)
dw 0x03FFF
i = i + 1
endw
while (i < 0x0200)
dw 0x03FFF
i = i + 1
endw
while (i < 0x0300)
dw 0x03FFF
i = i + 1
endw
while (i < 0x03FE)
dw 0x03FFF
i = i + 1
endw
endif
tris PORTB ; Save "w" in TRISB
xorwf PORTB, f ; XOR PORTB with the contents of "w"
end
For using the YAP-II, the application could be shortened by placing a 0x03FFF (not programmed) instruction every forty addresses or so. In this case, the short application would become:
title "SHORT - Designed for YAP-II"
;
; Look at a Two Instruction Application. Continually Update
; w (with the "unprogrammed" ADD 0x0FF) and then use the
; value for "PORTB" and "TRISB".
;
; Hardware Notes:
; 16F84 Running at 4 MHz in the YAP-II Programmer
; Reset is tied directly to Vcc and PWRT is Enabled.
; PortB is used for Output
;
;
; Myke Predko
;
; 00.10.12 - "Short" Updated for YAP-II Operation
; 99.10.26 - "Short" Created
;
list R=DEC
include "p16f84.inc"
__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF
org 0x0 ; Load Instructions to Program Memory
; End so there isn't a large "jump"
variable i = 0 ; in instructions the YAP can't handle
while (i < 0x03FE)
dw 0x03FFF
i = i + 40
endw
tris PORTB ; Save "w" in TRISB
xorwf PORTB, f ; XOR PORTB with the contents of "w"
end
In the original application, I loaded all the addresses with 0x03FFF so the YAP-II would
not have any problems with updating the internal PICmicro MCU program counter. In the
MPASM assembler, the "while" statement cannot execute more than 256 times or the assembler
will assume that the assembler calculator is in an endless loop. In the
second application, I "jump" twenty five times to load specific addresses with the 0x03FFF
word, which keeps the Program Counter correct for the final two instructions. This is
actually an easy way of making sure the YAP-II can program an application with large "holes"
in it without resorting to the "brute force" method I used originally.
|