Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to code a pic based speed trap

Status
Not open for further replies.

user1453

New Member
Hi

I am planning to build a coil gun and would like to have a way of meauring the muzzle velocity.

I could do this with multiple IC's, which I don't currently have.

A while ago I bought a programmer and a 16f628 and a 16f877 PIC's

I have a 4MHz ceramic oscilator and appropriate coupling capacitors. and 4 7 segment LED displays

Would it be possible for someone to give me a had writing the assembly code?

The easiers way that I could thing of doing this would be to use the 16f877 with two phototransistors and the 4 7 segment led displays.

The way I though the code would run would be

start
w=0
Is sensor 1 low
if not goto $-1
add 2 to W
is sensor 2 low
if not goto $-2
divide w by 10^6
divide 5x10^-3 by W
convert w into 4 decimal numbers store in temp1, temp2, temp3, temp4
display temp1 on 7 segment display1
display temp1 on 7 segment display1
display temp1 on 7 segment display1
display temp1 on 7 segment display1
is sensor 3 low
if notgoto $-5
goto start

with sensor 3 being a reset switch
sensors 1 and 2 being 5cm apart
would a program like this e pheasable?

I hsve not posted a schematic because I am not sure what ports to use
the speed should be between 0m and 50m per second
 
Last edited:
I'm by no means 1337 with picbasic, and this will most prolly need some sort of tweaking, but to the best of my knowledge, this program should point you in the right direction.

That said, you may have to modify the INTCON and OPTION register settings, for your pic's. The option register sets the timer to run off the internal clock and scale to 1:2 so that every interrupt, 512us pass.


Dim speed_meters_per_second as Float
Dim time_seconds as Float

Dim milliseconds as Float
Dim Temp as Byte


Symbol Timeout = Temp.0
Symbol Timout_Milliseconds = 2000
Symbol distance_apart_meters = 0.05
Symbol Sensor1 = Porta.0
Symbol Sensor2 = Porta.1


Device 16F84
Xtal = 4


ON_INTERRUPT Interrupt_Sub

INTCON = %10100000
Option_Reg = %00000000

Trisa.0=1
Trisa.1=1

start:

if sensor1=0 then goto start

setbit intcon,5
timeout=0
milliseconds=0
tmr0=0


timer:

if timeout=1 then
clearbit intcon,5
goto start
end if

if sensor2=0 then goto timer

time_seconds=milliseconds/1000

speed_meters_per_second=distance_apart_meters / time_seconds

print at 1,1,"Speed: ", speed_meters_per_second, " "

goto Start


Interrupt_Sub:

If intcon.2=1 then

milliseconds=milliseconds+.512

If milliseconds>Timout_Milliseconds then
timeout=1
Endif

Intcon.2=0

Endif


Return
 
Last edited:
I havn't got a pic basic compiler, just assembly, I wrote my example in the way I did so that people could understand what I was trying to do
 
can you get hold of a 16f84? if you can, i have tested and working code right here:

ON_INTERRUPT Interrupt_Sub


dim time_temp as word
dim milli_seconds as word
dim temp as byte

Dim speed_meters_per_second as word

dim numb1 as word

symbol timeout = temp.0
symbol sensor1 = porta.0
symbol sensor2 = porta.1
symbol distance_apart_micro_meters = 50000 '1 micro meter = 0.000001 of a meter
Symbol Timout_Milliseconds = 51



Device 16F84

Include "Template.inc"
Xtal = 4


trisa.0=1
trisa.1=1

LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4 ' 4-bit Interface
LCD_LINES = 2
LCD_TYPE = 0

PORTB_PULLUPS = ON 'set PORTB to allow pullups



INTCON = %00100000
Option_Reg = %00000000

delayms 200

cls

numb1=0

start:

numb1=numb1+1

if numb1=20000 then
print at 1,1,"Waiting. "
elseif numb1=40000 then
print at 1,1,"Waiting.. "
elseif numb1=60000 then
print at 1,1,"Waiting..."
numb1=0
end if

'goto start

if sensor1=0 then goto start

tmr0=0
time_temp=0
timeout=0
milli_seconds=0
setbit intcon,7

timer: 'Sensor1 has gone high - start speed trap

if timeout = 1 then
clearbit intcon,7 'error occured, sensor1 tripped somehow, reset
timeout=0
goto start
endif

if sensor2=0 then goto timer 'loop until sensor2 goes high

clearbit intcon,7 'stop timing

speed_meters_per_second = distance_apart_micro_meters / milli_seconds

speed_meters_per_second = speed_meters_per_second / 1000

'^^^^ convert to mm/ms which is always the same value as m/s
'eg:
' 50mm/ms /1000 to give m/ms
' =0.050m/ms *1000 to give m/s
' =50m/s
'
' fastest time possible (1 milli second from sensor to sensor)
' = 50000um/1ms
' = 50000um/ms /1000 to give mm/ms
' = 50mm/ms
' = 50m/s
'
' slowest time period is based on when the answer < 1
' as im not using floats(take too much memory) therefor:
'
' = 50000um/50ms
' = 1000um/ms /1000 to give mm/ms
' = 1mm/ms
' = 1m/s


cls

delayms 50

print at 1,1, "Speed: ", dec speed_meters_per_second, "m/s"

delayms 2000

cls

goto start 'goto start for next trap


Interrupt_Sub:

If intcon.2=1 then

time_temp=time_temp+128 'tmr0 int on 4Mhz = 128us

if time_temp > 1000 then
milli_seconds=milli_seconds+1
time_temp=time_temp-1000
endif

clearbit intcon,2
setbit intcon,7

Endif

Return
 
Last edited:
the HEX file for your pic
:02000000DC28FA
:08000800CF0003088301CE00C4
:100010000408CD009B2980308D00FE3097200130F0
:100020009720753092003030A7288D018D179A00E7
:10003000FE3097201A0897288C11100803198C1588
:1000400005308F00273094001030322003309400A8
:10005000E830322094016430322094010A3032209A
:100060001508392893001608920015089100BB2046
:10007000110891008F0303198C11100803194328EC
:100080000F02031808001108031D8C118C190800B9
:10009000303E9728980086110611831686110611A6
:1000A0000F308605831218088C1874283E30920091
:1000B0008030A7203330970088201330920088309A
:1000C000A72088206430A62088206430A620223013
:1000D00097008820283073200C307320063073205E
:1000E0008C14180874280C1497000C1C8228061114
:1000F000033C031C8728872005309200DC30A720B2
:10010000031408000C14FE3C0319952806150C1C5A
:100110000C1086150F3086051708F03986048611F5
:10012000970E0C1888283230A6201808D7288D1B67
:100130004A2894019300FF309307031C9407031C83
:10014000D72803309200DF30A7209B289201E83E99
:1001500091009209FC30031CB02891070318AD28C8
:1001600091070000920FAD281118B628911CBA28EB
:100170000000BA2808009601950110309700120D72
:10018000950D960D130895021408031C140F960282
:100190000318D1281308950714080318140F96079D
:1001A0000310910D920D970BBF281108D7288313C8
:1001B00083120313000008008C01831605148514B4
:1001C000811320308B008101C830831299200B20CD
:1001D000A301A201A20A0319A30A23084E3A203060
:1001E00003192206031D0C2980308D008030152054
:1001F00057304A2061304A2069304A2074304A2002
:1002000069304A206E304A2067304A202E304A201A
:1002100020304A204A204A2923089C3A40300319BA
:100220002206031D2B2980308D0080301520573089
:100230004A2061304A2069304A2074304A206930AF
:100240004A206E304A2067304A202E304A204A2009
:1002500020304A204A292308EA3A6030031922064E
:10026000031D4A2980308D008030152057304A20E8
:1002700061304A2069304A2074304A2069304A206F
:100280006E304A2067304A202E304A204A204A20C9
:10029000A301A20105184D29EA2881019C019B01B7
:1002A0001F109E019D018B171F1C59298B131F10B6
:1002B000EA2885185C2954298B13C33092005030EA
:1002C00091001E0894001D089300BB20A000120896
:1002D000A100210892002008910003309400E8302A
:1002E0009300BB20A0001208A1000B2032309920FF
:1002F00080308D008030152053304A2070304A20E5
:1003000065304A204A2064304A203A304A20203062
:100310004A20900121089600200895001C206D308D
:100320004A202F304A2073304A2007309400D030C2
:100330009A200B20EA280B1DB42902309C070330B9
:100340001C02031CB229031DA929E9301B02031C4E
:10035000B2299D0A03199E0AE8309B020330031C50
:0A036000013E9C020B118B170800F0
:02400E00F13F80
:00000001FF
 
Last edited:
Or if you want the source code?.

Code:
; Generated by WinPicProg 1.95f, (c) Nigel Goodwin June 2006.

            LIST      P=16F628A, F=INHX8M
            include "P16F628A.inc"
            __CONFIG 0x2118

; Variable definitions

            ORG     0x0000

            MOVLW   0x07
            MOVWF   ADCON0
            BSF     STATUS    , RP0
            MOVLW   0xF0
            MOVWF   TRISA
            BCF     STATUS    , RP0
            CLRF    PORTA
Label_0005  BTFSS   PORTA     , 07
            CALL    Label_0001
            BTFSS   PORTA     , 06
            CALL    Label_0002
            BTFSS   PORTA     , 05
            CALL    Label_0003
            BTFSS   PORTA     , 04
            CALL    Label_0004
            GOTO    Label_0005
Label_0001  CLRF    PORTA
            BSF     PORTA     , 03
            RETLW   0x00
Label_0002  CLRF    PORTA
            BSF     PORTA     , 02
            RETLW   0x00
Label_0003  CLRF    PORTA
            BSF     PORTA     , 01
            RETLW   0x00
Label_0004  CLRF    PORTA
            BSF     PORTA     , 00
            RETLW   0x00
 
 

            END
 
the specs:

PIC: PIC16F84A Flash 18-pin 1kB Microcontroller
Crystal: 4Mhz
Sensor 1: PORTA,0
Sensor 2: PORTA,1
Distance between sensors: 5cm (50mm or 50000micrometers)

Fastest speed: 50m/s
Slowest: 1m/s

Resolution: 50x(1ms fastest time, 50ms slowest time, 50 possible speeds with 1ms increments)

Testing: Hookup something like this:

**broken link removed**

i had to edit the RS and EN pins for the lcd, they were opposite on the picture, so thats why they arnt printed on the screen, instead near the wires as shown

EDIT: the resistors on the switchs can be anything around 10Kohm, and you can ditch the 4.7K resistor on the MCLR pin, just hook it straight to the 5V
 
Last edited:
that really doesnt look right man, there should be 434 words all up, im thinking its only part of it..

Nigel Goodwin said:
Or if you want the source code?.

Code:
; Generated by WinPicProg 1.95f, (c) Nigel Goodwin June 2006.

            LIST      P=16F628A, F=INHX8M
            include "P16F628A.inc"
            __CONFIG 0x2118

.
.
.
. **cut it out to save space
 
der.. im a newb, its says it on your profile, try

https://www.futurlec.com/LCDDisp.shtml


theres a 2*16 line one there for $6.90 US, im guessing thats ~$4 in your currency(im an aussie, no idea.. check it out on a currency converter site)

only down side, is that they can take upto 1.5 months to deliver, but that only happend when I ordered heaps of stuff, and there were probably a few they didnt have current stock of, but from other reviews, it varies, 2weeks-1month. they are soooo dirt cheap though, so theres no real point complaining hehe :eek:

https://www.maplin.co.uk/Home.aspx

will deffinetly have them in stock, and faster delivery, but they are sooo over priced man.. 26 pound for the same one, thats alot of coin...
 
gramo said:
that really doesnt look right man, there should be 434 words all up, im thinking its only part of it..

Sorry, I must have loaded the wrong HEX file somehow?.

How about this one?.

Code:
; Generated by WinPicProg 1.95f, (c) Nigel Goodwin June 2006.

            LIST      P=16F84A, F=INHX8M
            include "P16F84A.inc"
            __CONFIG 0x3FF1

; Variable definitions
Var_0001    EQU     0x4F
Var_0002    EQU     0x4E
Var_0003    EQU     0x4D
Var_0004    EQU     0x23
Var_0005    EQU     0x22
Var_0006    EQU     0x20
Var_0007    EQU     0x21

            ORG     0x0000

            GOTO    Label_0001
            ORG     0x0004
            MOVWF   Var_0001
            MOVF    STATUS    , W
            CLRF    STATUS
            MOVWF   Var_0002
            MOVF    FSR       , W
            MOVWF   Var_0003
            GOTO    Label_0002
Label_001A  MOVLW   0x80
            MOVWF   0x0D
            MOVLW   0xFE
            CALL    Label_0003
            MOVLW   0x01
            CALL    Label_0003
            MOVLW   0x75
            MOVWF   0x12
            MOVLW   0x30
            GOTO    Label_0004
Label_001C  CLRF    0x0D
            BSF     0x0D      , 07
            MOVWF   0x1A
            MOVLW   0xFE
            CALL    Label_0003
            MOVF    0x1A      , W
            GOTO    Label_0003
Label_0024  BCF     0x0C      , 03
            MOVF    0x10      , W
            BTFSC   STATUS    , Z
            BSF     0x0C      , 03
            MOVLW   0x05
            MOVWF   0x0F
            MOVLW   0x27
            MOVWF   0x14
            MOVLW   0x10
            CALL    Label_0005
            MOVLW   0x03
            MOVWF   0x14
            MOVLW   0xE8
            CALL    Label_0005
            CLRF    0x14
            MOVLW   0x64
            CALL    Label_0005
            CLRF    0x14
            MOVLW   0x0A
            CALL    Label_0005
            MOVF    0x15      , W
            GOTO    Label_0006
Label_0005  MOVWF   0x13
            MOVF    0x16      , W
            MOVWF   0x12
            MOVF    0x15      , W
            MOVWF   0x11
            CALL    Label_0007
            MOVF    0x11      , W
Label_0006  MOVWF   0x11
            DECF    0x0F      , f
            BTFSC   STATUS    , Z
            BCF     0x0C      , 03
            MOVF    0x10      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0008
            SUBWF   0x0F      , W
            BTFSC   STATUS    , C
            RETURN
Label_0008  MOVF    0x11      , W
            BTFSS   STATUS    , Z
            BCF     0x0C      , 03
            BTFSC   0x0C      , 03
            RETURN
            ADDLW   0x30
            GOTO    Label_0003
Label_0011  MOVWF   0x18
            BCF     PORTB     , 03
            BCF     PORTB     , 02
            BSF     STATUS    , RP0
            BCF     TRISB     , 03
            BCF     TRISB     , 02
            MOVLW   0x0F
            ANDWF   TRISB     , f
            BCF     STATUS    , RP0
            MOVF    0x18      , W
            BTFSC   0x0C      , 01
            GOTO    Label_0009
            MOVLW   0x3E
            MOVWF   0x12
            MOVLW   0x80
            CALL    Label_0004
            MOVLW   0x33
            MOVWF   0x17
            CALL    Label_000A
            MOVLW   0x13
            MOVWF   0x12
            MOVLW   0x88
            CALL    Label_0004
            CALL    Label_000A
            MOVLW   0x64
            CALL    Label_000B
            CALL    Label_000A
            MOVLW   0x64
            CALL    Label_000B
            MOVLW   0x22
            MOVWF   0x17
            CALL    Label_000A
            MOVLW   0x28
            CALL    Label_000C
            MOVLW   0x0C
            CALL    Label_000C
            MOVLW   0x06
            CALL    Label_000C
            BSF     0x0C      , 01
            MOVF    0x18      , W
            GOTO    Label_0009
Label_000C  BSF     0x0C      , 00
Label_0009  MOVWF   0x17
            BTFSS   0x0C      , 00
            GOTO    Label_000D
            BCF     PORTB     , 02
            SUBLW   0x03
            BTFSS   STATUS    , C
            GOTO    Label_000E
            CALL    Label_000E
            MOVLW   0x05
            MOVWF   0x12
            MOVLW   0xDC
            CALL    Label_0004
            BSF     STATUS    , C
            RETURN
Label_000D  BSF     0x0C      , 00
            SUBLW   0xFE
            BTFSC   STATUS    , Z
            GOTO    Label_000F
            BSF     PORTB     , 02
Label_000E  BTFSS   0x0C      , 00
Label_000A  BCF     0x0C      , 00
            BSF     PORTB     , 03
            MOVLW   0x0F
            ANDWF   PORTB     , f
            MOVF    0x17      , W
            ANDLW   0xF0
            IORWF   PORTB     , f
            BCF     PORTB     , 03
            SWAPF   0x17      , f
            BTFSC   0x0C      , 00
            GOTO    Label_000A
            MOVLW   0x32
            CALL    Label_000B
Label_000F  MOVF    0x18      , W
            GOTO    Label_0010
Label_0003  BTFSC   0x0D      , 07
            GOTO    Label_0011
Label_0019  CLRF    0x14
Label_0025  MOVWF   0x13
Label_0012  MOVLW   0xFF
            ADDWF   0x13      , f
            BTFSS   STATUS    , C
            ADDWF   0x14      , f
            BTFSS   STATUS    , C
            GOTO    Label_0010
            MOVLW   0x03
            MOVWF   0x12
            MOVLW   0xDF
            CALL    Label_0004
            GOTO    Label_0012
Label_000B  CLRF    0x12
Label_0004  ADDLW   0xE8
            MOVWF   0x11
            COMF    0x12      , f
            MOVLW   0xFC
            BTFSS   STATUS    , C
            GOTO    Label_0013
Label_0014  ADDWF   0x11      , f
            BTFSC   STATUS    , C
            GOTO    Label_0014
Label_0013  ADDWF   0x11      , f
            NOP
            INCFSZ  0x12      , f
            GOTO    Label_0014
            BTFSC   0x11      , 00
            GOTO    Label_0015
Label_0015  BTFSS   0x11      , 01
            GOTO    Label_0016
            NOP
            GOTO    Label_0016
Label_0016  RETURN
Label_0007  CLRF    0x16
            CLRF    0x15
            MOVLW   0x10
            MOVWF   0x17
Label_0018  RLF     0x12      , W
            RLF     0x15      , f
            RLF     0x16      , f
            MOVF    0x13      , W
            SUBWF   0x15      , f
            MOVF    0x14      , W
            BTFSS   STATUS    , C
            INCFSZ  0x14      , W
            SUBWF   0x16      , f
            BTFSC   STATUS    , C
            GOTO    Label_0017
            MOVF    0x13      , W
            ADDWF   0x15      , f
            MOVF    0x14      , W
            BTFSC   STATUS    , C
            INCFSZ  0x14      , W
            ADDWF   0x16      , f
            BCF     STATUS    , C
Label_0017  RLF     0x11      , f
            RLF     0x12      , f
            DECFSZ  0x17      , f
            GOTO    Label_0018
            MOVF    0x11      , W
            GOTO    Label_0010
Label_0010  BCF     STATUS    , IRP
            BCF     STATUS    , RP0
            BCF     STATUS    , RP1
            NOP
            RETURN
Label_0001  CLRF    0x0C
            BSF     STATUS    , RP0
            BSF     TRISA     , 00
            BSF     TRISA     , 01
            BCF     OPTION_REG, NOT_RBPU
            MOVLW   0x20
            MOVWF   INTCON
            CLRF    OPTION_REG
            MOVLW   0xC8
            BCF     STATUS    , RP0
            CALL    Label_0019
            CALL    Label_001A
            CLRF    Var_0004
            CLRF    Var_0005
Label_0020  INCF    Var_0005  , f
            BTFSC   STATUS    , Z
            INCF    Var_0004  , f
            MOVF    Var_0004  , W
            XORLW   0x4E
            MOVLW   0x20
            BTFSC   STATUS    , Z
            XORWF   Var_0005  , W
            BTFSS   STATUS    , Z
            GOTO    Label_001B
            MOVLW   0x80
            MOVWF   0x0D
            MOVLW   0x80
            CALL    Label_001C
            MOVLW   0x57
            CALL    Label_0011
            MOVLW   0x61
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x74
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x6E
            CALL    Label_0011
            MOVLW   0x67
            CALL    Label_0011
            MOVLW   0x2E
            CALL    Label_0011
            MOVLW   0x20
            CALL    Label_0011
            CALL    Label_0011
            GOTO    Label_001D
Label_001B  MOVF    Var_0004  , W
            XORLW   0x9C
            MOVLW   0x40
            BTFSC   STATUS    , Z
            XORWF   Var_0005  , W
            BTFSS   STATUS    , Z
            GOTO    Label_001E
            MOVLW   0x80
            MOVWF   0x0D
            MOVLW   0x80
            CALL    Label_001C
            MOVLW   0x57
            CALL    Label_0011
            MOVLW   0x61
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x74
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x6E
            CALL    Label_0011
            MOVLW   0x67
            CALL    Label_0011
            MOVLW   0x2E
            CALL    Label_0011
            CALL    Label_0011
            MOVLW   0x20
            CALL    Label_0011
            GOTO    Label_001D
Label_001E  MOVF    Var_0004  , W
            XORLW   0xEA
            MOVLW   0x60
            BTFSC   STATUS    , Z
            XORWF   Var_0005  , W
            BTFSS   STATUS    , Z
            GOTO    Label_001D
            MOVLW   0x80
            MOVWF   0x0D
            MOVLW   0x80
            CALL    Label_001C
            MOVLW   0x57
            CALL    Label_0011
            MOVLW   0x61
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x74
            CALL    Label_0011
            MOVLW   0x69
            CALL    Label_0011
            MOVLW   0x6E
            CALL    Label_0011
            MOVLW   0x67
            CALL    Label_0011
            MOVLW   0x2E
            CALL    Label_0011
            CALL    Label_0011
            CALL    Label_0011
            CLRF    Var_0004
            CLRF    Var_0005
Label_001D  BTFSC   PORTA     , 00
            GOTO    Label_001F
            GOTO    Label_0020
Label_001F  CLRF    TMR0
            CLRF    0x1C
            CLRF    0x1B
            BCF     0x1F      , 00
            CLRF    0x1E
            CLRF    0x1D
            BSF     INTCON    , GIE
Label_0023  BTFSS   0x1F      , 00
            GOTO    Label_0021
            BCF     INTCON    , GIE
            BCF     0x1F      , 00
            GOTO    Label_0020
Label_0021  BTFSC   PORTA     , 01
            GOTO    Label_0022
            GOTO    Label_0023
Label_0022  BCF     INTCON    , GIE
            MOVLW   0xC3
            MOVWF   0x12
            MOVLW   0x50
            MOVWF   0x11
            MOVF    0x1E      , W
            MOVWF   0x14
            MOVF    0x1D      , W
            MOVWF   0x13
            CALL    Label_0007
            MOVWF   Var_0006
            MOVF    0x12      , W
            MOVWF   Var_0007
            MOVF    Var_0007  , W
            MOVWF   0x12
            MOVF    Var_0006  , W
            MOVWF   0x11
            MOVLW   0x03
            MOVWF   0x14
            MOVLW   0xE8
            MOVWF   0x13
            CALL    Label_0007
            MOVWF   Var_0006
            MOVF    0x12      , W
            MOVWF   Var_0007
            CALL    Label_001A
            MOVLW   0x32
            CALL    Label_0019
            MOVLW   0x80
            MOVWF   0x0D
            MOVLW   0x80
            CALL    Label_001C
            MOVLW   0x53
            CALL    Label_0011
            MOVLW   0x70
            CALL    Label_0011
            MOVLW   0x65
            CALL    Label_0011
            CALL    Label_0011
            MOVLW   0x64
            CALL    Label_0011
            MOVLW   0x3A
            CALL    Label_0011
            MOVLW   0x20
            CALL    Label_0011
            CLRF    0x10
            MOVF    Var_0007  , W
            MOVWF   0x16
            MOVF    Var_0006  , W
            MOVWF   0x15
            CALL    Label_0024
            MOVLW   0x6D
            CALL    Label_0011
            MOVLW   0x2F
            CALL    Label_0011
            MOVLW   0x73
            CALL    Label_0011
            MOVLW   0x07
            MOVWF   0x14
            MOVLW   0xD0
            CALL    Label_0025
            CALL    Label_001A
            GOTO    Label_0020
Label_0002  BTFSS   INTCON    , T0IF
            GOTO    Label_0026
            MOVLW   0x02
            ADDWF   0x1C      , f
            MOVLW   0x03
            SUBWF   0x1C      , W
            BTFSS   STATUS    , C
            GOTO    Label_0027
            BTFSS   STATUS    , Z
            GOTO    Label_0028
            MOVLW   0xE9
            SUBWF   0x1B      , W
            BTFSS   STATUS    , C
            GOTO    Label_0027
Label_0028  INCF    0x1D      , f
            BTFSC   STATUS    , Z
            INCF    0x1E      , f
            MOVLW   0xE8
            SUBWF   0x1B      , f
            MOVLW   0x03
            BTFSS   STATUS    , C
            ADDLW   0x01
            SUBWF   0x1C      , f
Label_0027  BCF     INTCON    , T0IF
            BSF     INTCON    , GIE
Label_0026  RETURN
 
 

            END
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top