Serial Peripheral Interface Example Program

ORG     $0000   *MIKE ELLIS*
START     RMB   1       *Reserve memory byte*
END       RMB   1       *Reserve another memory byte*
*Tie SS line high
*Set appropriate data direction bits on port D
*Command line C:/as11 filename.asm > filename.lst will create
*listing file and generate S19 hex file named m.out
*I had a strange problem with the EVB and had to tie pin 8 on U7
*to pin 4 on U7 to make 68HC11 EVB communicate with the PC that was going
*to download the program. 
*8-N-1 protocol on connector P3 tied to the PC
*Using procomm, type , then load t, then hit PageUp for upload
*Then select 7 (ASCII), then type m.out and hit 
*After upload to EVB, type G C000 and program will run. 

        ORG     $C000    *ORIGIN*
        LDAA    #$55    *RESET COP*
        STAA    $103A   *BY WRITING AA*
        LDAA    #$AA    *AND THEN 55*
        STAA    $103A
        LDAA    #$03
        STAA    $1024   *DIVIDE E CLOCK BY 16*
        LDS     #$0040  *STACK
        LDY     #$1000  *POINTER TO REGISTERS
        LDAA    #$5C    *Initialize SPI
        STAA    $1028
        BSET    9,Y $18  *Data direction port d output
        BCLR    9,Y $21  *Data direction port d input
        BSET    4,Y $0D  *SPI ADDRESS BUS*
BEGIN:  LDAA    #$FF        
        STAA    $1004   * $1004 is I/O Port B
        LDAA    #$00    * Write FF and 00 successively to see if it works
        STAA    $1004
        LDAA    #$52
        STAA   $102A
XC:     LDAA    $1029
        ANDA    #$80
        BEQ     XC
        LDAA    $1029
        LDAA    #$55    *RESET COP*
        STAA    $103A   *BY WRITING AA*
        LDAA    #$AA    *AND THEN 55*
        STAA    $103A
        JMP     BEGIN


Return to 68HC11 Start Page