10-11-2020, 08:31 AM
Ovo sam odavno pronasao i pokusavao kad kako imam vremena da napravim ali nikako da proradi.Pronalazio sam neka objasnjenja ali nista u pic basic-u uvezi ovog programa pa ako neko zna gde je ovde greska da je ispravimo.Ja sam ovde samo dodao komande za lcd displej.
Quote:DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_RWREG PORTB
DEFINE LCD_RWBIT 3
DEFINE LCD_LINES 2
pause 100
capture VAR PIR1.2 ' CCP1 capture flag
overflow VAR PIR1.1 ' Timer1 overflow flag
period VAR WORD ' Word variable that stores the value
broj var word
TMR1_Vred Var word
TMR1_Vred = 64536
CCP1CON = %00000100 ' Enable the CCP1 capture, falling edge
T1CON = %00000011 ' TMR1 prescale=1, and turn it on (1uS per count)
mainloop:
IF (capture = 0) Then mainloop ' Wait here until captured
TMR1L = TMR1_Vred.lowbyte 'Postavi TMR1 na 64536
TMR1H = TMR1_Vred.highbyte
period.lowbyte = CCPR1L ' Store the captured value in
period.highbyte = CCPR1H ' period variable
IF overflow = 0 Then ' Skip the output if the timer overflowed
lcdout $FE, $80, "BROJ=",#period
EndIF
capture = 0 ' Clear the capture flag
reset:
IF (capture = 0) Then reset ' Wait for beginning of next period
TMR1L = 0 ' Clear Timer1 low register
TMR1H = 0 ' Clear Timer1 high register
capture = 0 ' Clear capture flag
overflow = 0 ' Clear overflow flag
GoTo mainloop ' Do it forever
End