Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

stop watch for motorola 68hc12 microprocessor

Status
Not open for further replies.

huntmine

Junior Member level 3
Junior Member level 3
Joined
Mar 7, 2002
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
220
hi, following is the code for the stop watch design, plz message me if the code can be optimized: the file is attached

***************************************************************
**THIS STOPWATCH WILL BE ABLE TO COUNT FROM TENTH SECOND TO 99
**SECONDS USING THE I/O PORTS OF 68HC11 MICROCONTROLLER. THE
**TENTH AND SECOND DIGITS WILL DISPLAY ON THE PORTB REGISTER.
**THE TEN SECOND DIGIT WILL DISPLAY ON THE PORTP'S BIT 0 TO
**BIT 3. BIT 4 TO BIT 7 OF PORT C REGISTER WILL BE USE AS
**INPUT BITS.
**************************************************************
*SYMBOL DEFINITION
***************************************************************
*68HC12 REGISTERS
PORTT EQU $240 OUTPUT PORT T REGISTER
DDRT EQU $242 DATA DIRECTION REGISTER T
PORTP EQU $258 I/O PORT P REGISTER
DDRP EQU $25A DATA DIRECTION REGISTER P
*MASK
BIT7 EQU %10000000 “START” BOTTON
BIT6 EQU %01000000 “PAUSE” BOTTON
BIT5 EQU %00100000 “RESET” BOTTON
*****************************************************************
**DATA SECTION
*****************************************************************
ORG $2000
NTYS EQU $2001 TEN SECONDS DIGIT LIMIT
TSS EQU $2002 TENTH AND SECOND LIMIT
TSCNT EQU $2003 TENTH SECOND COUNTER
TENSC EQU $2004 TEN SECONDS COUNTER
*****************************************************************
**MAIN PROGRAM
*****************************************************************
ORG $2200
*----------------------------------------------------------------
*SET UP THE LIMIT FOR TEN SECOND DIGIT
LDAA #$09
STAA NTYS
*SET UP THE LIMIT FOR TENTH AND SECOND DIGITS
LDAA #$63
STAA TSS
*INITIALIZE PORT P & PORT T
* SET BITS 0-3 AS OUTPUTS & 4-7 AS INPUTS
LDAA #$0F
STAA DDRP
* SET PORT T AS OUTPUT PORT T
LDAA #$FF
STAA DDRT
* INITIALIZE OUTPUTS TO ZEROS
RESET CLR PORTP
*INITIALIZE PORT T TO ZEROS
CLR PORTT
*RESETTING COUNTERS
CLR TSCNT
CLR TENSC
*-------------------------------------------------------------------
*IS “START”/”RESET” BOTTON PUSHED?
BPTST BRSET $258,BIT5 RESET IS “RESET” BOTTON PUSHED?
BRSET $258,BIT7 DELAY “START” COUNTING IF “START” BOTTON IS PUSHED
BRA BPTST RECHECK THE PUSH BOTTONS
*-------------------------------------------------------------------
*IS “PAUSE” BOTTON PUSHED?
PAUSE BRSET $258,BIT6 BPTST
BRA DELAY
*--------------------------------------------------------------------
*CHECKING IF IT HAS REACHED 9.9 SECONDS
CHECK LDAA TSCNT
CMPA TSS
BEQ INTENS
*INCREMENTING TENTH SECOND DIGIT
INC TSCNT
LDAA TSCNT
DAA

STAA PORTT
BRA PAUSE
*-------------------------------------------------------------------
*INCREMENTING TEN SECONDS DIGIT
INTENS CLR TSCNT “RESET” TENTH SECOND COUNTER
CLR PORTT “RESET” PORT T DISPLAY TO 00
*CHECKING IF TEN SECONDS COUNTER HAS REACHED 90 SECONDS
LDAA TENSC
CMPA NTYS
BEQ RTENSC
INC TENSC INCREMENTING TEN SECOND COUNTER
LDAA TENSC
STAA PORTP
BRA PAUSE
*RESETTING TEN SECONDS COUNTER WHEN IT REACHED 90 SECONDS
RTENSC CLR TENSC
CLR PORTP SET OUTPUTS OF PORTP TO ZEROS
BRA PAUSE SET OUTPUTS OF PORTP TO ZEROS
*-------------------------------------------------------------------
**0.1 SECOND DELAY
*-------------------------------------------------------------------
DELAY LDY #$FFFF
NOP
WAIT DEY
BNE WAIT
LDY #$7FFF
NOP
WAIT1 DEY
BNE WAIT1
BRA CHECK
 

can anyone show me how to attach the file
 

When you write a new topic, you can view below on the bottom of the web page a button that say "Examine". Press this an select the file, then press the button "Add Attachment" and next step is submit your message. Regards.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top