This is pretty crude, but see if it does what it should when changing to Forward, Back, etc
with your ESC.
Code:
DEFINE OSC 4
Match VAR WORD
Forward CON 1000 ' ~1mS pulse
Neutral CON 1500 ' ~1.5mS pulse
Back CON 2000 ' ~2mS pulse
Match = 20000 ' 20,000 * 1uS = 20mS until compare match
CCPR1H = Match.HighByte' Load compare register high
CCPR1L = Match.LowByte ' Load compare register low
CCP1CON = %00001011 ' Compare mode, auto reset Timer1
'/ TRIS & Port Setup
PORTB.0=1
TRISB = $FE ' PORTB.0 output, rest inputs
'/ disable interrupts
INTCON.7 = 0 ' Disable global ints
INTCON.6 = 0 ' Disable peripheral ints
PIE1.0 = 0 ' Disable Timer1 int
PIE1.2 = 0 ' Disable CCP1 int
T1CON = %00000000 ' Timer1 off, internal clock, 1:1 prescale
TMR1H = 0 ' Clear Timer1 high
TMR1L = 0 ' Clear Timer1 low
T1CON.0 = 1 ' Turn on Timer1
LOOPS: ' NOTE: PIR1.2 is the CCP1IF compare interrupt flag bit.
' this bit is set when Timer1 reaches the value in
' CCPR1L & CCPR1H
IF PIR1.2 = 1 THEN ' If CCP1 to TMR1 compare match occured
HIGH 0
PAUSEUS Forward ' change this to Neutral, Back, Forward to see effect
LOW 0
PIR1.2 = 0 ' Clear compare interrupt flag bit
ENDIF
GOTO LOOPS
END
Bookmarks