* Filename: PA6blink.asm * Sample program from MicroStamp11 Starter Package manual (pp. 10-11) * This program will cause an LED connected to PA6 to blink on and off every 1 second. ORG $8000 ;Store program at top of the 32kB of EEPROM in the MicroStamp11 32K Begin: LDAA #$04 ;Disable watchdog (COP) timer which is enabled by default STAA $3F ; Check Table 4-1 to verify that bit 2 at address $003F corresponds to NOCOP LDS #$FF ;Initialize the Stack Pointer (required when using subroutines or interrupts and ; we will be using a subroutine to create a delay.) Loop: LDAA #$40 ;Write a logic HIGH to PA6 to turn on an LED STAA $00 ; Check Table 4-1 to verify that bit 6 at address $0000 corresponds to PA6 BSR Delay ;Branch to subroutine at label Delay to create a 1/2 second delay LDAA #$00 ;Write a logic LOW to PA6 to turn off an LED STAA $00 BSR Delay ;Create another 1/2 second delay BRA Loop ;Create an infinite loop Delay: ;Subroutine to create a 1/2 second delay (at 8 MHz) LDY #$FFFF ;Load the Y-register with $FFFF (65535 decimal) D1: DEY ;Decrement the Y-register INY ;Increment the Y-register DEY ;Decrement the Y-register BNE D1 ;Branch if bit Z in CCR is not zero (i.e., loop until Y-register contains 0) RTS ;Return the the main program (to the memory address in the stack pointer) ORG $FFFE ;Define the Reset Vector so that it will point to the beginning of your FDB Begin ; code (marked by the Begin label). FDB - Form Double Byte. ;Note that every program requires a Reset Vector since this address is ; loaded into the Program Counter when the reset button is pressed. * Tested in lab and it works correctly. The LED blinks on and off (75 blinks/minute) at 9.8304 MHz. * Table 4-1 can be found in MC68HC11D3.pdf on the MicroStamp11 CD. * Note that PA6 is located on Hardware Pin 2 (see table on p.24 of MicroStamp11 Starter Package manual)