;**************************************************************************
;                            "Blink"
;
;                   Version 1.0  Revised 12/20/2002
;
;                        George Heron, N2APB
;                        2419 Feather Mae Ct.
;                        Forest Hill, MD  21050
;                        email: n2apb@amsat.org
;
;  Blink is a real simple program that demonstrates the absolute bare-minimal
;  code required to have the daughtercard do something (blink the heartbeat LED).
;
; For complete documentation and design details, see the web pages devoted for this
; project at http://www.njqrp.org/digitalhomebrewing/breadboard/breadboard.html.
;
; This code is intended to run on a Motorola 68HC908AB32 microcontroller and is
; best assembled within the Integrated Development Environment editor, provided free
; by Motorola as part of their HC908 development tool suite.
;
; Revision History:
; ----------------
; v1.0     12/20/2002      Initial version
;
;**************************************************************************
; Copyright 2002 by G. Heron, N2APB.  All rights reserved. For personal, non-profit use only.
;**************************************************************************

        include "../AB_REGS.INC"            ;MC68HC908GP32 register defimitions
        include "../macros.inc"             ;Macro instruction definition
        include "../local.inc"              ;Local variables

RAMStart     equ  $0050
RomStart     equ  $8000

    org RamStart

count_lo     ds   1
count_hi     ds   1

    org RomStart

;**************************************************************************
;   Vector Jump Table (located at start of User Area = 8000)
;**************************************************************************

_user_adc         jmp    Dummy_ISR     ; Insert jump to ADC vector code
_user_keyboard    jmp    Dummy_ISR     ; Insert jump to Keyboard vector code
_user_scitx       jmp    Dummy_ISR     ; Insert jump to SCI transmit vector code
_user_scirx       jmp    Dummy_ISR     ; Insert jump to SCI receive vector code
_user_scierr      jmp    Dummy_ISR     ; Insert jump to SCI error vector code
_user_timbch3     jmp    Dummy_ISR     ; Insert jump to TIMB Channel 3 Vector code
_user_timbch2     jmp    Dummy_ISR     ; Insert jump to TIMB Channel 2 Vector code
_user_spitx       jmp    Dummy_ISR     ; Insert jump to SPI transmit vector code
_user_spirx       jmp    Dummy_ISR     ; Insert jump to SPI receive vector code
_user_timb_of     jmp    Dummy_ISR     ; Insert jump to TIMB Overflow Vector code
_user_timb_ch1    jmp    Dummy_ISR     ; Insert jump to TIMB Channel 1 Vector code
_user_timb_ch0    jmp    Dummy_ISR     ; Insert jump to TIMB Channel 0 Vector code
_user_tima_of     jmp    Dummy_ISR     ; Insert jump to TIMA Overflow Vector code
_user_tima_ch3    jmp    Dummy_ISR     ; Insert jump to TIMA Channel 3 Vector code
_user_tima_ch2    jmp    Dummy_ISR     ; Insert jump to TIMA Channel 2 Vector code
_user_tima_ch1    jmp    Dummy_ISR     ; Insert jump to TIMA Channel 1 Vector code
_user_tima_ch0    jmp    Dummy_ISR     ; Insert jump to TIMA Channel 0 Vector code
_user_tim_of      jmp    Dummy_ISR     ; Insert jump to TIM Overflow Vector code
_user_pll         jmp    Dummy_ISR     ; Insert jump to PLL Vector code
_user_irq         jmp    Dummy_ISR     ; Insert jump to ~IRQ1 Vector code


_HCmon_LCD_disp   jmp    HCmon_LCD_disp ; vector (at $803C) for HCmon
                                        ; to display message to LCD

;**************************************************************************
; Main_Init - This is the point ($8040) where User Code starts executing
;             after coming from the Monitor
;             after board gets a RESET.
;**************************************************************************
Main_Init:
       sei                             ;disable all interrupts
       ldhx     #$01FF                 ;initialize
       txs                             ;  the stack pointer

;**************************************************************************
; PROGRAM MAINLINE                                                        *
;**************************************************************************

mymain:
        sta     copctl                 ;clear the COP counter

mm1:    bclr    6,portF                ;blink the heartbeat LED
        jsr     Wait500ms
        bset    6,portF
        jsr     Wait500ms
        bra     mm1

;**************************************************************************
;     HCmon_LCD_disp 
;*     Routine called from HCmon to display message to LCD                *
;**************************************************************************

HCmon_LCD_disp:
        rts                             ;just return to monitor (no display driver)


;***************************************************************
; Wait500ms -- Waits here for (4x250) x 500us = 500ms
;***************************************************************

wait500ms:
        lda     #4
        sta     count_hi
w500m1: lda     #$FA
        sta     count_lo
w500m2: jsr     wait500us
        dbnz    count_lo,w500m2
        dbnz    count_hi,w500m1
        rts

;**************************************************************************
; Wait500us -- Waits here for 500us
;**************************************************************************
wait500us:
        lda     #$79
w500u:  deca
        nop
        bne     w500u
        rts

**************************************************************
* DUMMY_ISR - Dummy Interrupt Service Routine.               *
*             Just does a return from interrupt.             *
**************************************************************
dummy_isr:
       nop
       rti           ; return



