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.

Sequential turn signal brake problem

Status
Not open for further replies.

ledmodder

New Member
I am new to programming and am having trouble with a brake output staying on. I am using a pic16f88 chip. The turn signals and hazzards work correctly but when I use the brake it goes into keyscan and turns off the output. I am using the btfss instruction for all inputs. Any help would be appreciated
 

Attachments

  • upload.txt
    2.1 KB · Views: 153
Hi,

Well your code seems rather incomplete, missing subroutines like Loop2 and hazard etc so itas not really possible to establish what your real problem is.

Also your code layout leaves a lot to be desired, have a look for the 16F88TEMP.asm file in the Templates folder of MPASM , this give you a basic layout of all the essential things, particularly the CONFIG line for things like OSC and WatchDog etc

Have a go with that and see if that helps, also try using MPLABs SIMulator where you can software wise step though your code and actually see what is happenig, come on back if you are still stuck.
 
I haven't written the code for the brake output cause I can't get output to stay on. I want the turn signals and brake to work at the same time.
 
I haven't written the code for brake cause I don't know how

Ok - fair enough , you are lost on getting going with the code, its a common problem getting over that first hurdle.

Best thing is start at the begining with the proverbial led flasher or similar.
If you see the Beginners "Sticky" post at the top of this forum there is a list of Tutorials etc.

Your can do a lot worse than this one by Nigel who frequents this forum.
 
Here is what I have so far. But I don't know how to keep brake output on. I goes off when I send the code back to keyscan.
 

Attachments

  • upload.asm
    6.6 KB · Views: 136
This code is quite inefficient there is only a super loop keyscan which CALLS a routine but there is no returns... if a call is made and the return is a mere 'goto' then the stack will fill up and no-one can keep tabs on it, there is no call to the brake routine or any variable to store the result in. Re-write all the routines to RETURN and a variable for left, right and brake. Then you can retrieve them in the loop.

Cheers Ian
 
So change all the goto commands at the end of each subroutine to return and create new keyscan loops for left,right and brake. And of course elininate the one super loop keyscan.
 
You are going to need the brake input on an interrupt as with this loop you can't get a uniform output when the indicators are on..

Code:
	list	p=pic16f88
	#include <p16f88.inc>
	__CONFIG _CONFIG1, _INTRC_IO & _WDT_OFF & _LVP_OFF & _PWRTE_OFF &  _MCLR_ON & _BODEN_ON & _CPD_OFF & _WRT_PROTECT_OFF & _CCP1_RB0 & _CP_OFF &_INTRC_IO
	__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF    
	 errorlevel -302; gets rid of bank select error
	 
;;;;;;;;;;;;;;Set up the constants;;;;;;;;;;;
	TIME 	equ 9fh
	PORTB	equ 06h
	TRISB	equ 86h
	PORTA	equ 05h
	TRISA	equ 85h
	STATUS	equ 03h
	RA0	equ H'0000'
	RA1	equ H'0001'
	RA2	equ b'0000010'
	Temp	equ 0ch
	NOT_RPBU	equ  H'0007'
	RB4		equ b'00001000'
	cblock 0x20;declaring registers
		d1
		d2
		d3
		;          register1;resister21
		;          register2;register22
	        ;          register3;register23
	        ;          register4;register24
	endc
;;;;;;;;;;;;;;;Pattern Data Definition;;;;;;;
;		'1':on '0':off
;;;;;;;;;;;;;;;LEFTturn pattern;;;;;;;;;;;;;;

	p00	equ b'00100000'
	p01	equ b'01000000'
	p02	equ b'10000000'
	
;;;;;;;;;;;;;;;RIGHTturn pattern;;;;;;;;;;;;;
	
	p03	equ b'00000100'
	p04	equ b'00000010'
	p05	equ b'00000001'
	
;;;;;;;;;;;;;;;HAZZARD pattern;;;;;;;;;;;;;;;
	
	p06	equ b'00100100'
	p07	equ b'01000010'
	p08	equ b'10000001'
	
;;;;;;;;;;;;;;;BRAKE pattern;;;;;;;;;;;;;;;;;

	p09 	equ b'00001000'
	p10 	equ b'00000000'
	
;;;;;;;;;;;;;ALTERNATE PATTERNS;;;;;;;;;;;;;;
;;;;;;;;;;;;;LEFTturn1;;;;;;;;;;;;;;;;;;;;;;;;

	p11	equ b'00100000'
	p12	equ b'01100000'
	p13	equ b'11100000' 
	
;;;;;;;;;;;;RIGHTturn1;;;;;;;;;;;;;;;;;;;;;;;;

	p14	equ b'00000100'
	p15	equ b'00000110'
	p16	equ b'000000111'
	
;;;;;;;;;;;;HAZZARD pattern1;;;;;;;;;;;;;;;;;

	p17	equ b'00100100'
	p18	equ b'01100110'
	p19	equ b'11100111'
	p20 	equ b'00000000'; off pattern
	
;;;;;;;;;;;;;;;Program Start;;;;;;;;;;;;;;;;;
	
	
	org 0				;reset vector
	goto 	init
	org 4				;interrupt vector
	goto 	init
;;;;;;;;;;;;;;Set up the ports;;;;;;;;;;;;;;;
	org	5
init
	bsf 	STATUS,5
	movlw 	b'01100000'
	movwf 	OSCCON
WaitForStableOscillator
	btfss 	OSCCON,IOFS
	goto 	WaitForStableOscillator
	movlw 	b'11111000'			; OPTION_REG setup
	movwf 	OPTION_REG             
	clrf 	PIE1				;
	clrf 	PIE2				; No peripherial interrupt
	clrf 	ANSEL				; No analog to digital conversion
	clrf 	TXSTA				;Disable AUSART
	bcf 	STATUS,5
	clrf 	INTCON				;No Interrupt control
	clrf 	CCP1CON				;Capture/Compare/PWM Disabled
	clrf 	T1CON				;No TIMER 1
	
	;Watchdog Timer
	bsf 	83h,5
	movlw 	b'00010111'
	movwf 	WDTCON
	bcf	WDTCON,SWDTEN			;Disable watchdog timer
	bsf 	STATUS,5
						;PSA must be to WDA (bsf OPTION_REG,psa)
	bcf 	OPTION_REG,PS2
	bcf 	OPTION_REG,PS1
	bsf 	OPTION_REG,PS0
	bcf 	STATUS,5
	
	;General
	clrf 	RCSTA				;Disable AUSART receive
	clrf 	ADCON0				;No analog to digital conversion
START 
	banksel ANSEL
	movlw	0
	movwf	ANSEL
	banksel CVRCON
	bcf	CVRCON,CVROE
    	bsf 	STATUS,RP0   			;SWITCH BANK0 TO BANK1
	movlw	b'11111111'			;SET INPUTS
	movwf	TRISA  				;TO TRISA
	movlw   b'00000000'			;SET outputs
	movwf   TRISB
	bcf	STATUS,RP0
	
;;;;;;;;;;;;;Check if the bits are high;;;;;;;;;
keyscan
	call	BRAKE
    	clrf    PORTB
	btfss	PORTA,RA0
	goto	keyscan1
	btfss	PORTA,RA1
	call	LEFTturn
	goto	keyscan2
keyscan1
    	clrf    PORTB
	btfss	PORTA,RA1
	goto 	keyscan
	call	RIGHTturn
	goto	keyscan
keyscan2
	call	HAZZARD	
    	goto	keyscan
    	
;;;;;;;;;;;;LEFTTURNsubroutine;;;;;;;;;;;;;;;;;;
LEFTturn
      	call 	LOOP2	
	movlw 	p00	;Set pattern data
	movwf 	PORTB	;Output data
	call 	LOOP2
	movlw 	p01	;Set pattern data
	movwf 	PORTB
	call	LOOP2
	movlw 	p02
	movwf 	PORTB
	call 	LOOP2
	goto 	keyscan
	
;LEFTturn; alternate pattern1
      	call 	LOOP2	
	movlw 	p11	;Set pattern data
	movwf 	PORTB	;Output data
	call 	LOOP2
	movlw 	p12	;Set pattern data
	movwf 	PORTB
	call 	LOOP2
	movlw 	p13
	movwf 	PORTB
	call 	LOOP2
	return
	
;;;;;;;;;;;;RIGHTturn Subroutine;;;;;;;;;;;;;;;;;
RIGHTturn
	call 	LOOP2
	movlw 	p03
	movwf	PORTB
	call 	LOOP2
	movlw	p04
	movwf	PORTB
	call 	LOOP2
	movlw	p05
	movwf 	PORTB
	call 	LOOP2
	return
	
;RIGHTturn; alternate pattern1
	call 	LOOP2
	movlw 	p14
	movwf	PORTB
	call 	LOOP2
	movlw	p15
	movwf	PORTB
	call 	LOOP2
	movlw	p16
	movwf 	PORTB
	call 	LOOP2
	return
    
;RIGHTturn; alternate pattern2
	call 	LOOP2
	movlw 	p14
	movwf	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw	p15
	movwf	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw	p16
	movwf 	PORTB
	call 	LOOP2
	return

;;;;;;;;;;;;;HAZZARD Subroutine;;;;;;;;;;;;;;;;;
HAZZARD
	call 	LOOP2	
	movlw 	p06
	movwf 	PORTB
	call 	LOOP2
	movlw 	p07
	movwf 	PORTB
	call 	LOOP2
	movlw 	p08
	movwf 	PORTB
	call 	LOOP2
	return
	
;HAZZARD; alternatwe pattern1
	call 	LOOP2	
	movlw 	p17
	movwf 	PORTB
	call 	LOOP2
	movlw 	p18
	movwf 	PORTB
	call 	LOOP2
	movlw 	p19
	movwf 	PORTB
	call 	LOOP2
	return
	
;HAZZARD; alternatwe pattern2
	call 	LOOP2	
	movlw 	p17
	movwf 	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw 	p18
	movwf 	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw 	p19
	movwf 	PORTB
	call 	LOOP2
	return
;;;;;;;;;;;;;;;;;;;;;;;;;;BRAKE subroutine;;;;;;;;;;;;;;;
BRAKE
	btfss 	PORTA,RA2
	return
	call 	LOOP1
	movlw 	p09
	movwf 	PORTB
	call 	LOOP1
	movlw 	p10
	movwf 	PORTB
	call 	LOOP1
	movlw 	p09
	movwf 	PORTB
	call 	LOOP1
	movlw 	p10
	movwf 	PORTB
	call 	LOOP2
BRAKE1
	movlw 	p09
	movwf 	PORTB
	return
 
	;;;;;;;;;;;;;Delay Loop;;;;;;;;;;;;;;;;;;;;;;;;;
LOOP0	;1/8 sec delay
 	movlw 	0xa7
 	movwf 	d1
 	movlw 	0x62
 	movwf 	d2
Delay_0
 	decfsz 	d1,f
 	goto 	$+2
 	decfsz 	d2,f
 	goto 	Delay_0
 	goto 	$+1
 	return
LOOP1	;1/4 sec delay
 	movlw 	0x4f
 	movwf 	d1
 	movlw 	0xc4
 	movwf 	d2
Delay_1
	decfsz d1,f
	goto $+2
	decfsz d2,f
	goto Delay_1
	goto $+1
	return
LOOP2;	1/2 sec delay
	movlw 	0x03
	movwf 	d1
	movlw 	0x18
	movwf 	d2
	movlw 	0x02
	movwf 	d3
Delay_2
	decfsz 	d1,f
	goto 	$+2
	decfsz 	d2,f
	goto 	$+2
	decfsz 	d3,f
	goto 	Delay_2 ;6cycles
	goto 	$+1
	goto 	$+1
	goto 	$+1
	return
end

Cheers Ian
 
That why I said use interrupts... However thinking about this this is another candidate for a state machine.

Create an output buffer called "lights" and a time keeper, then cycle through the loop like so..

process turns ... set appropriate bits in buffer
process hazard ... set appropriate bits in buffer
process brake ... set appropriate bits in buffer
blit buffer to port
delay for visual

hey presto all the lights will correspond to the input signals
this way if you set left or right, hazard can overrule and it will look good
if you run two cycle keepers (timekeepers) you can delay the smallest time ie..(brake lights)
then double / treble the delay for the hazard / turn signals.

Cheers Ian
 
Last edited:
Someting like this..
Code:
	list	p=pic16f88
	#include <p16f88.inc>
	__CONFIG _CONFIG1, _INTRC_IO & _WDT_OFF & _LVP_OFF & _PWRTE_OFF &  _MCLR_ON & _BODEN_ON & _CPD_OFF & _WRT_PROTECT_OFF & _CCP1_RB0 & _CP_OFF &_INTRC_IO
	__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF    
	 errorlevel -302; gets rid of bank select error
	 
;;;;;;;;;;;;;;Set up the constants;;;;;;;;;;;
	TIME 	equ 9fh
	PORTB	equ 06h
	TRISB	equ 86h
	PORTA	equ 05h
	TRISA	equ 85h
	STATUS	equ 03h
	RA0	equ H'0000'
	RA1	equ H'0001'
	RA2	equ b'0000010'
	Temp	equ 0ch
	NOT_RPBU	equ  H'0007'
	RB4		equ b'00001000'
	lightbuffer	equ 30h
	turnpattern	equ 31h
	brakepattern	equ 32h
	cblock 0x20;declaring registers
		d1
		d2
		d3
		;          register1;resister21
		;          register2;register22
	        ;          register3;register23
	        ;          register4;register24
	endc
;;;;;;;;;;;;;;;Pattern Data Definition;;;;;;;
;		'1':on '0':off
;;;;;;;;;;;;;;;LEFTturn pattern;;;;;;;;;;;;;;

	p00	equ b'00100000'
	p01	equ b'01000000'
	p02	equ b'10000000'
	
;;;;;;;;;;;;;;;RIGHTturn pattern;;;;;;;;;;;;;
	
	p03	equ b'00000100'
	p04	equ b'00000010'
	p05	equ b'00000001'
	
;;;;;;;;;;;;;;;HAZZARD pattern;;;;;;;;;;;;;;;
	
	p06	equ b'00100100'
	p07	equ b'01000010'
	p08	equ b'10000001'
	
;;;;;;;;;;;;;;;BRAKE pattern;;;;;;;;;;;;;;;;;

	p09 	equ b'00001000'
	p10 	equ b'00000000'
	
;;;;;;;;;;;;;ALTERNATE PATTERNS;;;;;;;;;;;;;;
;;;;;;;;;;;;;LEFTturn1;;;;;;;;;;;;;;;;;;;;;;;;

	p11	equ b'00100000'
	p12	equ b'01100000'
	p13	equ b'11100000' 
	
;;;;;;;;;;;;RIGHTturn1;;;;;;;;;;;;;;;;;;;;;;;;

	p14	equ b'00000100'
	p15	equ b'00000110'
	p16	equ b'000000111'
	
;;;;;;;;;;;;HAZZARD pattern1;;;;;;;;;;;;;;;;;

	p17	equ b'00100100'
	p18	equ b'01100110'
	p19	equ b'11100111'
	p20 	equ b'00000000'; off pattern
	
;;;;;;;;;;;;;;;Program Start;;;;;;;;;;;;;;;;;
	
	
	org 0				;reset vector
	goto 	init
	org 4				;interrupt vector
	goto 	init
;;;;;;;;;;;;;;Set up the ports;;;;;;;;;;;;;;;
	org	5
init
	bsf 	STATUS,5
	movlw 	b'01100000'
	movwf 	OSCCON
WaitForStableOscillator
	btfss 	OSCCON,IOFS
	goto 	WaitForStableOscillator
	movlw 	b'11111000'			; OPTION_REG setup
	movwf 	OPTION_REG             
	clrf 	PIE1				;
	clrf 	PIE2				; No peripherial interrupt
	clrf 	ANSEL				; No analog to digital conversion
	clrf 	TXSTA				;Disable AUSART
	bcf 	STATUS,5
	clrf 	INTCON				;No Interrupt control
	clrf 	CCP1CON				;Capture/Compare/PWM Disabled
	clrf 	T1CON				;No TIMER 1
	
	;Watchdog Timer
	bsf 	83h,5
	movlw 	b'00010111'
	movwf 	WDTCON
	bcf	WDTCON,SWDTEN			;Disable watchdog timer
	bsf 	STATUS,5
						;PSA must be to WDA (bsf OPTION_REG,psa)
	bcf 	OPTION_REG,PS2
	bcf 	OPTION_REG,PS1
	bsf 	OPTION_REG,PS0
	bcf 	STATUS,5
	
	;General
	clrf 	RCSTA				;Disable AUSART receive
	clrf 	ADCON0				;No analog to digital conversion
START 
	banksel ANSEL
	movlw	0
	movwf	ANSEL
	banksel CVRCON
	bcf	CVRCON,CVROE
    	bsf 	STATUS,RP0   			;SWITCH BANK0 TO BANK1
	movlw	b'11111111'			;SET INPUTS
	movwf	TRISA  				;TO TRISA
	movlw   b'00000000'			;SET outputs
	movwf   TRISB
	bcf	STATUS,RP0
	movlw	03h
	movwf	turnpattern
	movlw	02h
	movwf	brakepattern
	clrf	PORTB
	
;;;;;;;;;;;;;Check if the bits are high;;;;;;;;;
keyscan
	clrf	lightbuffer
	btfss 	PORTA,RA2
	call	BRAKE
	decfsz	turnpattern
	goto	keyscan1
	movlw	3h
	movwf	turnpattern
keyscan1
	btfss	PORTA,RA0
	call	RIGHTturn
	btfss	PORTA,RA1
	call	LEFTturn
	movf	lightbuffer,w
	movwf	PORTB
	call	LOOP2
    	goto	keyscan
    	
;;;;;;;;;;;;LEFTTURNsubroutine;;;;;;;;;;;;;;;;;;
LEFTturn
	movf	turnpattern,w
	sublw	3h
	btfss	STATUS,Z
	goto	left1
	movlw 	p00
	xorwf	lightbuffer
	goto 	rightfin
left1 
	movf	turnpattern,w
	sublw	2h
	btfss	STATUS,Z
	goto	left2
	movlw	p01
	xorwf	lightbuffer
	goto	leftfin
left2
	movlw	p02
	xorwf 	lightbuffer	
leftfin
	return
	
;LEFTturn; alternate pattern1
      	call 	LOOP2	
	movlw 	p11	;Set pattern data
	movwf 	PORTB	;Output data
	call 	LOOP2
	movlw 	p12	;Set pattern data
	movwf 	PORTB
	call 	LOOP2
	movlw 	p13
	movwf 	PORTB
	call 	LOOP2
	return
	
;;;;;;;;;;;;RIGHTturn Subroutine;;;;;;;;;;;;;;;;;
RIGHTturn
	movf	turnpattern,w
	sublw	3h
	btfss	STATUS,Z
	goto	right1
	movlw 	p03
	xorwf	lightbuffer
	goto 	rightfin
right1 
	movf	turnpattern,w
	sublw	2h
	btfss	STATUS,Z
	goto	right2
	movlw	p04
	xorwf	lightbuffer
	goto	rightfin
right2
	movlw	p05
	xorwf 	lightbuffer	
rightfin
	return
	
;RIGHTturn; alternate pattern1
	call 	LOOP2
	movlw 	p14
	movwf	PORTB
	call 	LOOP2
	movlw	p15
	movwf	PORTB
	call 	LOOP2
	movlw	p16
	movwf 	PORTB
	call 	LOOP2
	return
    
;RIGHTturn; alternate pattern2
	call 	LOOP2
	movlw 	p14
	movwf	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw	p15
	movwf	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw	p16
	movwf 	PORTB
	call 	LOOP2
	return

;;;;;;;;;;;;;HAZZARD Subroutine;;;;;;;;;;;;;;;;;
;HAZZARD
	decfsz	turnpattern	
	goto 	haz1
	movwf 	PORTB
	call 	LOOP2
	movlw 	p07
haz1
	movwf 	PORTB
	call 	LOOP2
	movlw 	p08
	movwf 	PORTB
	call 	LOOP2
	return
	
;HAZZARD; alternatwe pattern1
	call 	LOOP2	
	movlw 	p17
	movwf 	PORTB
	call 	LOOP2
	movlw 	p18
	movwf 	PORTB
	call 	LOOP2
	movlw 	p19
	movwf 	PORTB
	call 	LOOP2
	return
	
;HAZZARD; alternatwe pattern2
	call 	LOOP2	
	movlw 	p17
	movwf 	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw 	p18
	movwf 	PORTB
	call 	LOOP2
	movlw 	p20
	movwf 	PORTB
	call 	LOOP0
	movlw 	p19
	movwf 	PORTB
	call 	LOOP2
	return

;;;;;;;;;;;;;;;;;;;;;;;;;;BRAKE subroutine;;;;;;;;;;;;;;;
BRAKE	decfsz	brakepattern
	goto	brake1
	movlw 	p09
	movwf 	lightbuffer
	movlw	2h
	movwf	brakepattern
	return
brake1	
	movlw 	p10
	movwf 	lightbuffer
	return
 
	;;;;;;;;;;;;;Delay Loop;;;;;;;;;;;;;;;;;;;;;;;;;
LOOP0	;1/8 sec delay
 	movlw 	0xa7
 	movwf 	d1
 	movlw 	0x62
 	movwf 	d2
Delay_0
 	decfsz 	d1,f
 	goto 	$+2
 	decfsz 	d2,f
 	goto 	Delay_0
 	goto 	$+1
 	return
LOOP1	;1/4 sec delay
 	movlw 	0x4f
 	movwf 	d1
 	movlw 	0xc4
 	movwf 	d2
Delay_1
	decfsz d1,f
	goto $+2
	decfsz d2,f
	goto Delay_1
	goto $+1
	return
LOOP2;	1/2 sec delay
	movlw 	0x03
	movwf 	d1
	movlw 	0x18
	movwf 	d2
	movlw 	0x02
	movwf 	d3
Delay_2
	decfsz 	d1,f
	goto 	$+2
	decfsz 	d2,f
	goto 	$+2
	decfsz 	d3,f
	goto 	Delay_2 ;6cycles
	goto 	$+1
	goto 	$+1
	goto 	$+1
	return
end

not much changed but you can play with it

Cheers Ian
 
Last edited:
The last program I couldn't get anything to work. The one before this worked except that the brake signal wouldn't stay on solid. I wanted the brake signal to flash twice and then stay on solid even when the left, right and hazzard signals were on. Thanks again for the help. and of course want the brake lights to come on first before the turn and hazzard signals.
 
The whole program can be done much simpler with a single routine.
Here is the start of the project with the circuit diagram:

CarTurnHazzardBrake.gif


Here is a sample .asm
 

Attachments

  • CarTurnHazzardBrake.asm
    2.8 KB · Views: 128
Last edited:
The whole program can be simplified to this:

Code:
SetUp    bsf        status,rp0    
        clrf    trisA            
        decf    trisA            ;Make all RA input
        clrf    trisB            ;Make all RB output        
        bcf        status,rp0        ;select programming area - bank0 
        clrf     portB            ;Clear Port B of junk             
        movlw    07h                ;turn comparators off and enable
        movwf    cmcon            ;    pins for I/O functions    
        goto    Main                                

;****************************************************************
;* 1mS Delay                            *
;****************************************************************
    
_1mS    nop
        decfsz     del,f
        goto     _1mS
        retlw     00
        
;****************************************************************
;* Main                             *
;****************************************************************

Main    movlw   0FFh
        movwf    counter        ;number of 1mS loops
        movf    portA,w        ;copy portA to w
        movwf   portB       ;w to portB
        call    _1mS        
        call    _1mS
        decfsz    counter,1
        goto    Main+2
        movlw   0FFh
        movwf    counter        ;number of 1mS loops
        bcf        portB,0
        bcf        portB,1
        bcf        portB,2
        call    _1mS
        btfss    portA,3        ;is brake OFF?
        bcf        portB,3
        decfsz    counter,1
        goto    $-4        
        goto    Main
                        
        END
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top