If you do something like this you can calculate My_value in XXX Us from tour timer1 setup
YOU need to find timer1 settings Prescaler value and Timer1 Value for XXXUs you like to use
[code:1:7604c8e0e1]$regfile = "m32def.dat"
$crystal = 8000000 '14.745600
$hwstack = 40
$swstack = 40
$framesize = 40
Set Mcucsr.7 'JTAG disable
Set Mcucsr.7
Ddrd = &B00011110 ' cnfig pins as IN (0) OUT (1)
Portd = 0
Dim Flag As Byte , My_value As Long Count As Long
Config Timer1 = Timer , Prescale = Xxxx ' setup timer1 prescaler value
Timer1 = Xxxxx 'setup timer1 valur for you XXX Us tick
On Ovf1 Timer1_isr
Enable Timer1
Start Timer1
Enable Interrupts
Portd = 0
Do
If Flag = 1 Then
Flag = 0
Toggle Portd.4 ' test make PortD.1 blink every 1 sec (timer1 = 51136)
End If
Loop
' ADD the UP DOWN for buttons and make it Incr/Decr My_value for how many Us you like
End
Timer1_isr:
Timer1 = Xxxxx 'setup timer1 valur for you XXX Us tick
Incr Count ' count UP xxxx Us from timer1 value
If Count => My_value Then 'My_value is how many times xxxx Us you like'
Flag = 1
A = 0
End If
Return[/code:1:7604c8e0e1]
↧