Using Adapt912DT60 EVB

View: New views
1 Messages — Rating Filter:   Alert me  

Using Adapt912DT60 EVB

by jrsdorfman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.  I have been tasked with programming a timer board and haven't used assembler in almost 15 years.

I am using the Adapt912DT60 EVB and would like to take advantage of the Output Compare feature of the Mu.

I am using the MiniIDE for coding, compiling and flashing..
I have been successful with simple programs.. turning on ports.. reading ports.. making software loops and delays... but now I would like to use the interrupts.. and cannot seem to.. I am sure it is a simple thing .. but to expedite I need help.

The EVB does programs okay.. but PG7 only flashes at 10Hz when I run it.

Here is the code I have just completed (below):


I hope someone can point me in the right direction.. thanks in advance.

Jonathan

;****************************************************************************************
; This program is to output a pulse to the PORTT bit 2 and turn an LED on/off as well

*REVISION HISTORY:
*
*DATE                   REV.NO.          DESCRIPTION
*
*Mar. 13, 2009           1.00   Initial release, Runs at 8Mhz
*
*Revised by JRSD for the ADAPT912DT60A
;****************************************************************************************

#include REGD60.INC

; Operation Parameters
rbase       EQU     $0000 ;68HC912D60 register block
RAM         EQU     $0200               ;68HC912D60 internal RAM
STACK       EQU     $0800 ;Stack at top of internal ram
EEPROM      EQU     $0c00 ;68HC912D60  internal EEPROM
FLASH       EQU     $8000 ;68HC912D60  internal FLASH memory
CODE        EQU     $8000 ;Start of Flash

; Equates define needed
FourBITS:   EQU    %00001111 ;Mask all bits
ALLBITS:    EQU    %11111111 ;Mask all bits
BIT7:       EQU    %10000000 ;Mask for Bit7
BIT6:       EQU    %01000000 ;Mask for Bit6
BIT5:       EQU    %00100000 ;Mask for Bit5
BIT4:       EQU    %00010000 ;Mask for Bit4
BIT3:       EQU    %00001000 ;Mask for Bit3
BIT2:       EQU    %00000100 ;Mask for Bit2
BIT1:       EQU    %00000010 ;Mask for Bit1
BIT0:       EQU    %00000001 ;Mask for Bit0
C1F:    EQU    %00000010 ;Output compare 1 Flag
TEN:    EQU    %10000000 ;Timer Enable
BUFH:    EQU    $0210
count:    EQU    $0220
HALF_P: EQU 16000


        ORG RAM

dum     ds      1 ;1 byte of dummy RAM variable
temp    ds      1 ;another byte of dummy RAM variable

        ORG     FLASH
RESET:                         ;Start of code on RESET
;Initialize Stack

        lds     #STACK ;initialize stack pointer

;Initialize PORT G & H
; bset DDRG,  BIT6 ;PORT G bit7 as an output: ARMED FLAG;
; bclr PORTG, BIT6 ;clear port g bit 7

;start of code

        bset TSCR,TEN ;enable timer
        bset TIOS,%00000100 ;enable OC chan 2
        ldd TCNT ;current TCNT
        std TC2 ;write OC register 2
        movb #%0000100,TFLG1 ;reset CF2
        bclr TMSK1,%00000100 ;set CI1 to enable ch. 2 interrupt

        bclr TCTL2,%00100000 ;clear OM2
        bset TCTL2,%00010000 ;clear OL2


        cli ;enable cpu interrupt

main: wai ;wait for interrupt
        bra main
       
;interrupt subroutine
OC2_isr:
        ldd TC2
        addd #HALF_P
        std TC2 ;write OC register 2

        movb #%0000100,TFLG1 ;reset CF2

        rti

        ORG $FFEA
        ds.w OC2_isr