Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic16f84 single pulse blinks led

Status
Not open for further replies.

liklik2k10

Newbie level 5
Joined
Jul 12, 2010
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Philippines
Activity points
1,342
Hi everyone!

I have a problem in my project. I was told to make a program in assembly such that when a pulse is received in an input pin, the led connected to an output pin blinks 5 times. after that the program goes back on that input pin and waits for another signal to come. it's like this:

1. when the power is on, a program loops on a certain pin waiting for an input pulse
2.when a pulse is received,it jumps to a program that blinks the led 5 times in an output pin
3. after 5 blinks,the program goes back again on the loop where it waits for another pulse, and the cycle continues

I'm sorry i'm really new to this. I know this is very basic for you all but for me it's so hard.. :cry:

Thanks for the help guys! :D
 

Can you please post the program??

and i hope you know you have to say which pin is input and which pin is output, you have to do that in the TRISA or TRISB register - and those are in bank 1!! So thirst set bit 03h,05h for bank-switch, then give him the inputs/ouputs and then clear bit 83h,05h for bank-switch.

ok?
 
Thanks for the help guys!

if you cannot turn something that simple to a working piece of code, you should go back to books and take some classes because no amount of help (in the form of giving you a piece of working code) is going to help you.

As a matter of fact, anyone providing you a piece of working code is doing you a disfavor.

you don't need help. you need lots of learning, on your part.
 
Hi...Goto this link & read it carefully...itll help u in creatings delays...

www.sonofsofaman.com/hobbies/electronics/pic/16f84/code/delays.asp

Now after that u main program should have something like this...

Start: Wait here unless pin goes high
2. O/p pin high
3. Delay
As many times u repeat line 2 & 3 ull get blinks for the same time...then after repeating it 4 times more...
Goto start

Try writing it using instructions...

Regards.
 
Thanks a lot!

I'll follow all your instructions. I'll read the basics of assembly tonight.

I'll ask questions tomorrow if i got confused of this.

I appreciated all your help.

Thanks!
 

Hi everyone. I decided to stop working on the program before because I got busy in the past months. Now I've decided to continue. I made this program last night.


STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h

bsf STATUS,5
movlw 01h ;sets up bit 0 which is RA0 to input while bits 1,2,3,4 to output
movwf TRISA
bcf STATUS,5

Start BTFSS PORTA,0 ;checks if the input in bit 0 pin in port A is high or low. If high skip the next line.
goto Start
Call Blink
Call Blink
Call Blink
Call Blink
Call Blink
goto Start

Blink
movlw 02h ;writes 02h or 00010 to the W register
movwf PORTA ;moves the contents of W (02h) onto portA
call Delay
movlw 00h
movwf PORTA
call Delay

Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
end

Is this correct?
 

I just glanced at your code, there appears to be a "return" missing after the Blink routine:

Blink
movlw 02h ;writes 02h or 00010 to the W register
movwf PORTA ;moves the contents of W (02h) onto portA
call Delay
movlw 00h
movwf PORTA
call Delay
return

Otherwise Blink will not return to the original point of execution after the routine has completed. Execution will instead drop into the Delay Routine.

BigDog
 
Thanks a lot! I'll try to add the return function. I'll post it here after I've made this. One thing... Is the BTFSS function correct or should I use BTFSC?
 

The BTFSS appears to be the correct choice, Bit Test File Skip if Set.

You are testing that input pin for a switch closure, correct?

Make sure you use the proper pullup resistors and current limiting resisters in your design.

I checkout your code further and let you know if I find any other issues.

BigDog
 
Hi BigDog. I tried the code using this circuit
pushbutton_for_blinking_Led_ckt.JPG
and I just changed the output pin from RB0/INT in the diagram to RA1, following the code that I made. I tested the voltages and they're fine. The output LED still didn't blink. What should I do?
 

Hi BigDog,

Please help me with this. Is the circuit above correct? Thanks in advance. :smile:
 

liklik2k10;957605I tried the code using this circuit and I just changed the output pin from RB0/INT in the diagram to RA1 said:
Is your current revision of your code listing in reply #6 above or have you made significant changes?

If you have made significant changes, please post the latest version in this discussion thread.

BigDog
 

Hi,
Change your code to:
Code:
LIST P=16F84
INCLUDE "P16F84.inc"
__CONFIG 0x3FF1

;STATUS equ 03h
;TRISA equ 85h
;PORTA equ 05h

COUNT1 equ 08h
COUNT2 equ 09h

org 0x00 ; You did not write this  -------------------------------------------------

bsf STATUS,5
movlw 01h ;sets up bit 0 which is RA0 to input while bits 1,2,3,4 to output
movwf TRISA
bcf STATUS,5

Start BTFSS PORTA,0 ;checks if the input in bit 0 pin in port A is high or low. If high skip the next line.
goto Start
Call Blink
Call Blink
Call Blink
Call Blink
Call Blink
goto Start

Blink
movlw 02h ;writes 02h or 00010 to the W register
movwf PORTA ;moves the contents of W (02h) onto portA
call Delay
movlw 00h
movwf PORTA
call Delay
return

Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
end

By using
Code:
LIST P=16F84
, you are defining which controller you are using.
By using
Code:
INCLUDE "P16F84.inc"
, you no longer have to define the SFRs (PORTA, TRISA, etc).
By using
Code:
__CONFIG 0x3FF1
, you are defining the configuration bits.

Code:
org 0x00
0x00 is the reset vector where the microcontroller jumps on startup and reset. You did not write this in your code.

Instead of
Code:
movlw 02h ;writes 02h or 00010 to the W register
movwf PORTA ;moves the contents of W (02h) onto portA
call Delay
movlw 00h
movwf PORTA
call Delay
you can write
Code:
bsf PORTA, 1
call delay
bcf PORTA, 1
call delay

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top