| ??? 12/01/03 12:16 Read: times |
#59695 - RE: 6 Decimal Digits Counter Responding to: ???'s previous message |
Well then I think the microcontroller will be excellent for this application!! I would suggest that if the rate is slow enough (like below 250 Hz) why don't you simply consider connecting the event input into the external interrupt pin such as INT0 and let the microcontroller process an interrupt for each event. The interrupt service routine can then simply implement a software counter for 6 digits in six memory locations. Since you are simply counting you can accumulate digit counts directly so you most easily manipulate the count for later display, storage or logging. (others may suggest you count in binary format across 3 bytes but this then must be converted to base 10 format digits for display.
Your interrupt routine can use a simple piece of code as follows to increment the six digit number.
; in the internal RAM
DIGITS6:
DS 6
;
;code within the ISR
;
CNTUP:
MOV R0, #DIGITS6
MOV R2, #6
CNTLP:
INC @R0
CJNE @R0, #10, CNTCP
CNTCP:
JC CNTDN
MOV @R0, #0
INC R0
DJNZ R2, CNTLP
;
CNTDN:
....
Michael Karas |



