hi i made this program to count some 2ms pulse and light a led on
now when i'm going to compile it the compiler output is
"Error in library timer.h: incorrect parameters in Set. expected: Set variale bit status"
this is the software
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Include files (Libraries)
#include <timer.h>
;Defines (Constants)
#define Switch PORTB.0
#define Led PORTB.1
;Variables
Dim RCsignal As byte
;Interrupt Handlers
On Interrupt PORTBChange Call measure
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
InitTimer1 Osc, PS1_1/8
ClearTimer 1
Wait Until switch = 1
StartTimer 1
Wait Until switch = 0
StopTimer 1
RCsignal = TMR1L
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 16F84A doesn't have a Timer 1 so you're getting those errors in timer.h as the timer 1 bits aren't valid. (GCBasic's low level libraries are automatically included so you don't need the line that includes timer.h)
You could try using timer 0 although StartTimer and StopTimer won't do anything as timer 0 has no on/off. You might want to move the InitTimer line to the initialisation part of the program as well. Timer 0 isn't ideal for measuring pulse widths accurately though.
The interrupt on port B change only works on PORTB.4 to PORTB.7 so you might need to change the switch input to one of those. The following code compiles -
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Defines (Constants)
#define Switch PORTB.4
#define Led PORTB.1
;Variables
Dim RCsignal As byte
;Interrupt Handlers
DummyRead = PORTB
set RBIF off
On Interrupt PORTBChange Call measure
InitTimer0 Osc, PS0_1/8
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
Wait Until switch = 1
ClearTimer 1
Wait Until switch = 0
RCsignal = TMR0
DummyRead = PORTB ' Clear the mismatch
End Sub
It might work with a following wind! The led may not indicate much except that a measurement has been made at least once.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Defines (Constants)
#define Switch PORTB.4
#define Led PORTB.1
;Variables
Dim RCsignal As byte
;Interrupt Handlers
DummyRead = PORTB
set RBIF off
On Interrupt PORTBChange Call measure
InitTimer0 Osc, PS0_1/8
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
Wait Until switch = 1
ClearTimer 0
Wait Until switch = 0
RCsignal = TMR0
DummyRead = PORTB ' Clear the mismatch
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi i made this program to count some 2ms pulse and light a led on
now when i'm going to compile it the compiler output is
"Error in library timer.h: incorrect parameters in Set. expected: Set variale bit status"
this is the software
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Include files (Libraries)
#include <timer.h>
;Defines (Constants)
#define Switch PORTB.0
#define Led PORTB.1
;Variables
Dim RCsignal As byte
;Interrupt Handlers
On Interrupt PORTBChange Call measure
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
InitTimer1 Osc, PS1_1/8
ClearTimer 1
Wait Until switch = 1
StartTimer 1
Wait Until switch = 0
StopTimer 1
RCsignal = TMR1L
End Sub
The 16F84A doesn't have a Timer 1 so you're getting those errors in timer.h as the timer 1 bits aren't valid. (GCBasic's low level libraries are automatically included so you don't need the line that includes timer.h)
You could try using timer 0 although StartTimer and StopTimer won't do anything as timer 0 has no on/off. You might want to move the InitTimer line to the initialisation part of the program as well. Timer 0 isn't ideal for measuring pulse widths accurately though.
The interrupt on port B change only works on PORTB.4 to PORTB.7 so you might need to change the switch input to one of those. The following code compiles -
It might work with a following wind! The led may not indicate much except that a measurement has been made at least once.
Forgot to edit the ClearTimer 1 line.
hello Nobody
thank you very much for your clarifications
hope not to disturb you for gcb problems…
have a nice day