;*******************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more     *
;* advanced functionality of this processor, please see the        *
;* demonstration applications, located in the examples             *
;* subdirectory of the "Freescale CodeWarrior for HC08" program    *
;* directory.                                                      *
;*******************************************************************

; Include derivative-specific definitions
            INCLUDE 'derivative.inc'
            
;
; export symbols
;
            XDEF _Startup
            ABSENTRY _Startup

;
; variable/data section
;
            ORG Z_RAMStart 
count:		RMB    5           
            
            ORG    RAMStart         ; Insert your data definition here
ExampleVar: DS.B   1


;
; code section
;
            ORG    ROMStart
; all-gpios initialisation - type: output, state: log.1, pullups-off
gpio_init:
        lda     #$FF
        sta     PTFDD
        
        lda     #$00
		sta 	PTFD
		
;       clra
;       sta     PTFPE

        rts
;- GPIO_INIT --------------------------------------------------------------------------------            


_Startup:
            LDHX   #RAMEnd+1        ; initialize the stack pointer
            TXS
            CLI						; enable interrupts
      
			lda     #$00			; set System Power Management Status and Control 1 Register (SPMSC1) so that MCU
		    sta     SPMSC1			; runs without LVI support
		    
		    lda     #$00			; set System Options Register (SOPT) so that MCU runs without COP support
		    sta     SOPT
		    
            jsr gpio_init

mainLoop:
            ; Insert your code here
            bset    0,PTFD   ; pin 0 of LED array
            bclr    0,PTFD
            
	       	bset    1,PTFD   ; pin 1 of LED array
            bclr    1,PTFD

            BRA    mainLoop
        
  
;**************************************************************
;* spurious - Spurious Interrupt Service Routine.             *
;*             (unwanted interrupt)                           *
;**************************************************************

spurious:				; placed here so that security value
			NOP			; does not change all the time.
			RTI

;**************************************************************
;*                 Interrupt Vectors                          *
;**************************************************************

            ORG	$FFFA

			DC.W  spurious			;
			DC.W  spurious			; SWI
			DC.W  _Startup			; Reset
