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.

Help with input output

Status
Not open for further replies.

rskumar89

New Member
Hi
I have written a code to operate leds when the trigger is applied at port.A1.
and when it detects the trigger i want it to send a pulse to RB3 first then RB2.
Pulse duration to be 1 sec.
But when i connect the circuit i dont get outputs at RB3 and RB2.
To trouble shoot i inserted a line in the program to start an led as soon as the trigger is applied at RB1.

Pls help friends...

;********************* AutoCall.asm 12/25/07 **********************
;********************************************************************

LIST P=16F84A ; Device number (PIC16F84A)
ERRORLEVEL -302 ;remove message about using proper bank
;--------------------- Define Variables -----------------------------

STATUS equ 03h ; Status register
TRISA equ 85h ; I/O control for port A
TRISB equ 86h ; I/O control for port B
PORTB equ 06h ; Address of port B
PORTA equ 05h ; Address of port A
CounterA equ 0x0C ; General purpose registers
CounterB equ 0x0D ;
CounterC equ 0x0E ;

start bsf STATUS,5 ; Select memory bank 1 (01)
movlw b'00000000'
movwf TRISB ; Set port B as output,
movlw b'11111' ;
movwf TRISA ; Set port A as INPUT,
bcf STATUS,5 ; Reset to bank 0
goto Switch_Open ;

Switch_Open ;------------------ Wait for switch open

movlw b'00000001' ; start test led
movwf PORTB ;
btfsc PORTA,1 ; Look at pin A1
goto Switch_Open ; Loop until pin A1 is low
movlw b'00000010' ; trigger detect led
movwf PORTB ;
movlw D'6' ; 1 sec delay start
movwf CounterC
movlw D'24'
movwf CounterB
movlw D'168'
movwf CounterA
loop decfsz CounterA,1
goto loop
decfsz CounterB,1
goto loop
decfsz CounterC,1
goto loop ; 1 sec delay stop
movlw b'00001000' ; press 1 led
movlw D'6' ; 1 sec delay start
movwf CounterC
movlw D'24'
movwf CounterB
movlw D'168'
movwf CounterA
loop2 decfsz CounterA,1
goto loop2
decfsz CounterB,1
goto loop2
decfsz CounterC,1
goto loop2
movwf PORTB ; ; 1 sec delay stop
movlw b'00000000' ;
movwf PORTB ;
movlw D'6'
movwf CounterC
movlw D'24'
movwf CounterB
movlw D'168'
movwf CounterA
loop1 decfsz CounterA,1
goto loop1
decfsz CounterB,1
goto loop1
decfsz CounterC,1
goto loop1
movlw b'00000100' ; press 2 led
movlw D'6'
movwf CounterC
movlw D'24'
movwf CounterB
movlw D'168'
movwf CounterA
loop12 decfsz CounterA,1
goto loop12
decfsz CounterB,1
goto loop12
decfsz CounterC,1
goto loop12
movwf PORTB ;
movlw b'00000000' ;
movwf PORTB ;
end

the problem is that the leds at RB2 and RB3 are not flashing.


cheers,
Linus
 
Last edited:
Hi
I have written a code to operate leds when the trigger is applied at port.A1.
and when it detects the trigger i want it to send a pulse to RB3 first then RB2.
Pulse duration to be 1 sec.
But when i connect the circuit i dont get outputs at RB3 and RB2.
To trouble shoot i inserted a line in the program to start an led as soon as the trigger is applied at RB1.

Pls help friends...



the problem is that the leds at RB2 and RB3 are not flashing.


cheers,
Linus

hi,
The problem is with the delay routines, the program gets stuck in an infinite loop.

When I take out the delays, B2 and B3 flash once, then the program runs off the end.:)
 
but then each of the delay routine correspond to 1 sec since i use a 4MHz crystal.
now if i take the delay off the flashing would be fast.
how do i make a one sec delay ?
 
but then each of the delay routine correspond to 1 sec since i use a 4MHz crystal.
now if i take the delay off the flashing would be fast.
how do i make a one sec delay ?

hi,
Google for PICloops calculator copy and paste the code and call the subr when you want the delay.
 
Status
Not open for further replies.

Latest threads

Back
Top