;   *****  LPC900 NoTouch  - ISP Bootloader  *****
;
; Executive Summary: How to activate the ISP Bootloader from within your appication code.
;                    without specific tricky hardware.
;
; Written by Joseph Goldburg    5th Feb 2007
;
; Hardware:  Keil  MCB900 Board
;
; Purpose:
; To demonstrate how to activate the P89LPC932A1   ISP Bootloader Based on ErikM ealier work
;
; Concept:  LPC900  ISP Bootloader Entry:
; ISP hardware entry via 3 pulses jumps to 1F00h  (for LPC932A1 and LPC935).
; SO... why not directly call 1F00h (as per the example below)
;
; Note:  Other LPC900 Micro's may have a different ISP bootloader address
;
; Application Program:
; Turn on ALL LEDs on Port 2
; Wait for swich  P0_1 to go high
; Turn all LEDs off
; Turn on  one LED Port2_1 to indicate jumping to boot loader
; Jump to bootloader...

; Additonal comments
; Once this program has been loaded in to the LPC932A1 successfully - the hardware entry method 
; can be turned off (under Advanced Options --> Hardware Config --> Don't use DTR for RST).

	org 0000
	
P2M1	equ	  0a4h
P2M2	equ	  0a5h

Port2	equ	   0a0h    ;  8 LEDs on port2
Port2_1	equ	   0a1h    ;  Just 1 on port2 (bit 1)
Port2_5 equ        0a5h    ;  another LED

Port0_1	equ	   81h     ; Boot loader test swtich bit Port 0  bit 1

boot	equ	  01f00h	  ; Boot loader jump address for 8k P89LPC932A1
; boot	equ	  xxxxx   	  ; Boot loader jump address for for othe LPC900 devices	
;
; ----------------  User  Code here ---------------	
	mov     P2M1,#00     ; 
	mov	P2M2,#0ffh   ;  Set Port 2 to output push_pull
	
	mov	Port2,#0ffh   ; Set Port 2 (turn all 8 LEDs on)

; --- User code needs to test swicth on P0.1
loop: 	
	jnb    Port0_1,loop    ;  loop if P0.1 is low
; 
; -----------------------------------------------------

; Port_0_1 is high  - switch is high  ----
; Handoff to bootloader starts here
	mov    Port2,#00h    ; 
	setb   Port2_1       ;  trun 1 LED on to indicate we are jumping to the boot loader

	jmp 	boot	     ; jump tp boot loader

; shouldn't get here
        setb    Port2_5      ; signal LED we have dropped through the code.
	jmp $

end
