YES but Pulse received will be called when the motor runs.
The purpose of the TimerCount test is to put the LEDon when the modor is not runing and clear the Timer1 to 0
Sub PulseReceived (TimeCount As word, CapturedTime As word)
TimeCount = CapturedTime ' store Alias CCPR1H,CCPR1L
Set CCP1IF = 0 ' Clear CCP Interrupt Flag
PilotCounter += 1 ' increment
IF PilotCounter = 5 Then PilotCounter = 1 ' ready for new revolution
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know what value your clock has but if you don't stoptimer1 before Ledon Cleartimer 1 , an interupt can occurs and sub pulsereceived will be called again before wait 100 ms is achieved .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a calculation to do from timer count.
Why this code does not work at the DO LOOP begining ?
**…/…
On Interrupt CCP1 Call PulseReceived
T1CON = b'00001001' "Set up timer1 PS1_1/1
ClearTimer 1
StartTimer 1
Do
LEDoff
TimerMax:
If TimerCount > 65500 Then "word variable Alias TMR1H,TMR1L
LEDon
ClearTimer 1
wait 100 ms
StartTimer 1
Goto TimerMax
End If
…./….
Code with calculation from TimerCount As Word Alias TMR1H,TMR1L
and use of CCP1 Capture or Compare
…./….
LOOP
**
Hi,
In sub "Pulsereceived" , do you increment Timercount ( Timercount ++) for each overflow ?
YES but Pulse received will be called when the motor runs.
The purpose of the TimerCount test is to put the LEDon when the modor is not runing and clear the Timer1 to 0
Sub PulseReceived (TimeCount As word, CapturedTime As word)
TimeCount = CapturedTime ' store Alias CCPR1H,CCPR1L
Set CCP1IF = 0 ' Clear CCP Interrupt Flag
PilotCounter += 1 ' increment
IF PilotCounter = 5 Then PilotCounter = 1 ' ready for new revolution
End Sub
I don't know what value your clock has but if you don't stop timer1 before Ledon Cleartimer 1 , an interupt can occurs and sub pulsereceived will be called again before wait 100 ms is achieved .