 ;Example program for using the the REVA board's LEDs, buttons and switches
; with the RAISONANCE assembler.

;Displays, on the LEDs, the value of the buttons and switches
;BT6 will not work because it has no pullup.

;Note that you must put the jumpers for the LEDs, buttons and switches.

;This also shows how you must protect the ICC pins in order to debug.


$include(st72345.inc)

;-------------------------------------------------------------------------------
;   Constants
;-------------------------------------------------------------------------------
	NULL			EQU 	0

;-------------------------------------------------------------------------------
;   Segments
;-------------------------------------------------------------------------------

	RSG?DATA			 	segment		DATA INPAGE0
	RSG?CODE			 	segment		CODE
	
	
;-------------------------------------------------------------------------------
;   Data
;-------------------------------------------------------------------------------

rseg RSG?DATA
_readval:
	ds	1
_count:
	ds	1

;-------------------------------------------------------------------------------
;   Code
;-------------------------------------------------------------------------------

rseg RSG?CODE
_reset:

	;reset stack pointer
  	RSP
  	;mask interrupts
  	SIM
  	
   ;initialize the ports' config
	LD A, #0h
	LD PBOR, A
	LD PBDDR, A
	LD PCOR, A
	LD PCDDR, A
	
;main function. that's where the debug session goes at the beginning.
_main:
  	
  	;configure port C as output push-pull
	LD A, #0AFh ;be careful to leave the ICC pins alone if you want to debug.
	LD PCDDR, A
	LD PCOR, A
	
  	;configure port B as input pull-up
	LD A, #0FFh
	LD PBOR, A
	
_main_loop:

	;read the buttons and switches
	LD A, PBDR
	
	AND A, #03Fh
	
	;ICCDATA is PC4
	LD _readval, A
	BTJF _readval, #4, _PB4is0
	OR A, #080h
_PB4is0:

	;display value on the LEDs
	LD PCDR, A

	JP	_main_loop

;----------------------------------------------------------------
; VECTORS table

cseg at 0FFFEh

   dw    _reset         ;RESET
			
END 










