Gonna need more info than this... Like how fast should it count? What pin is the button connected to? Is the button de-bounced? What langauage is the program to be written in?
anyway... heres a basic 'C' program you can use.
Code:
byte x = 0;
for( ; x < 99; x++ )
{
if( button )
{
break;
}
delay_ms(100);
}
And you program counts from 0-255, not from 0-99, You need to add COMWF instruction to limit number od cycles. (I don't know if there is one for 16F though..)
And you program counts from 0-255, not from 0-99, You need to add COMWF instruction to limit number od cycles. (I don't know if there is one for 16F though..)
There isn't, but my tutorial 10.1 does the 0-99 count, the main part of the program looks like this:
Code:
Main
call Delay255
call Delay255
call Delay255
call Delay255
incf ones, f
movf ones, w ;test first digit
sublw 0x0A
btfss STATUS, Z
goto Main
clrf ones
incf tens, f
movf tens, w ;test second digit
sublw 0x0A
btfss STATUS, Z
goto Main
clrf tens
goto Main ;loop for ever
[quote]
It simply increments two GPR's called 'ones' and 'tens', and loops back to zero after 99 - the actual displaying is done by the interrupt driven multiplexing routine.[/quote]
If you use a PIC that doesn't have TMR2, you would need to rewrite the routines, I use TMR2 because it's far better (and easier to use) than the older ones. Although in this particular case, just for multiplexing, no great accuracy is required.
No, I haven't used the 84 for years, I moved to the 628 when it replaced the 84.
But as I said, the only difference in the counter program is the seven segment timer interrupt routines, it would be fairly simple to alter it accordingly.
For that matter, does it need to have a display?, the non-working code posted earlier made no effort to have a display driven by the PIC.