led blink pic 16F877

S

sinner

Guest
I've tried (with no success) to get a simple led blink program running on
the 16F877. !MCLR is +5v through a 10k res, Vdd is +5v, Vss is 0V, I have
a .1uF ceramic cap across Vdd and Vss. OSCout is pulsing, which makes me
think the chip is 'running' and not locked up. I have a canned
oscillator on OSCin. To avoid floating inputs, I have set all pins as
outputs.

Here is my code, beter yet, does anyone have a known working led blink for
this chip? It would help infinitely.

http://www.cs.ttu.edu/~marquez/pic/

only led_blink.asm and p16f877 are being used to blink an led on RD_0.

Thanks anyone.
 
Hi All,
You need to place a 1K resistor or higher on MCLR, with a
capacitor of 100nF or higher, one side of resistor goes to Vdd, one side of
cap goes to Gnd.

+
|
R
|
----------MCLR
|
C
|
gnd


You may also have the problem, that the unit is flashing, but you haven't
calculated the on / off times correctly and it is flashing at a higher
frequency than the eye can detect.

Below is a sample code for PIC 12F675 for led flasher

include "p12f675.inc"
;******************************************************
org 0000
bcf status,5
clrf gpio
movlw b'00000111'
movwf cmcon
movlw b'00000000'
movwf intcon
movlw b'00110101'
movwf t1con
bsf status,5
clrf trisio
movlw b'00000001'
movwf pie1
movlw b'11000111'
movwf option_reg
clrf ansel
bcf status,5
movlw b'00010000'
movwf gpio
movlw b'00000000'
;******************************************************
loop btfsc pir1,0
goto bitset
goto loop
bitset btfsc gpio,4
goto set1
btfss gpio,4
goto clear1
set1 bcf gpio,4
bcf pir1,0
goto loop
clear1 bsf gpio,4
bcf pir1,0
goto loop
end


I have also found the chips can be a little susceptable to outside noise, so
you may require 4K7 resistors on unused inputs, although for this project
it's not really required.

Before anyone mentions the weak pull ups (WPU), I found they were not really
enough to block the noise and stop false triggering of the chip

Paul
 
"loedown" <zero242@internode.on.net> wrote in message
news:41ecd75d$1@duster.adelaide.on.net...
Hi All,
You need to place a 1K resistor or higher on MCLR, with a
capacitor of 100nF or higher, one side of resistor goes to Vdd, one
side of
cap goes to Gnd.
No you don't, MCLR can be tied directly to Vcc as long as the PS rise
time is fast enough and ICSP is not being used. Your method is a
probably a better idea though.

+
|
R
|
----------MCLR
|
C
|
gnd


You may also have the problem, that the unit is flashing, but you
haven't
calculated the on / off times correctly and it is flashing at a higher
frequency than the eye can detect.
This is possibly what he did. He only has a 100mS delay between toggles
of the LED and his code is dependant upon a 4MHz crystal. He also needs
to do some more initialization.

Below is a sample code for PIC 12F675 for led flasher

include "p12f675.inc"
;******************************************************
org 0000
bcf status,5
clrf gpio
movlw b'00000111'
movwf cmcon
movlw b'00000000'
movwf intcon
movlw b'00110101'
movwf t1con
bsf status,5
clrf trisio
movlw b'00000001'
movwf pie1
movlw b'11000111'
movwf option_reg
clrf ansel
bcf status,5
movlw b'00010000'
movwf gpio
movlw b'00000000'
;******************************************************
loop btfsc pir1,0
goto bitset
goto loop
bitset btfsc gpio,4
goto set1
btfss gpio,4
goto clear1
set1 bcf gpio,4
bcf pir1,0
goto loop
clear1 bsf gpio,4
bcf pir1,0
goto loop
end


I have also found the chips can be a little susceptable to outside
noise, so
you may require 4K7 resistors on unused inputs, although for this
project
it's not really required.
The safest thing to do with unused inputs is to make them into unused
outputs. ;-)

Before anyone mentions the weak pull ups (WPU), I found they were not
really
enough to block the noise and stop false triggering of the chip
They are pretty weak, something like 50k IIRC.
 
"sinner" <dont@mailme.com> wrote in message
news:pan.2005.01.18.02.46.52.428833@mailme.com...
I've tried (with no success) to get a simple led blink program running
on
the 16F877. !MCLR is +5v through a 10k res, Vdd is +5v, Vss is 0V, I
have
a .1uF ceramic cap across Vdd and Vss. OSCout is pulsing, which makes
me
think the chip is 'running' and not locked up. I have a canned
oscillator on OSCin. To avoid floating inputs, I have set all pins as
outputs.

Here is my code, beter yet, does anyone have a known working led blink
for
this chip? It would help infinitely.

http://www.cs.ttu.edu/~marquez/pic/

only led_blink.asm and p16f877 are being used to blink an led on RD_0.
What speed oscillator are you using? If you are using something faster
than 4MHz, then changes need to be made to your delay routines or they
will run too fast. Also the OPTION register is in BANK1 so you have to
set RP0 (or use the banksel macro) to see it from your WAIT macro. To
get TMR0 running you have to clear (bcf) T0CS in the OPTION register,
unless you are supplying a clock input to the RA4/T0CKI pin. You should
not enable GIE or T0IE unless you really wish to get interrupts.
 
Here is my code, beter yet, does anyone have a known working led blink for
this chip? It would help infinitely.
Blink-a-led code and circuits for most flash PICs:
http://www.voti.nl/blink


Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
Webshop for PICs and other electronics
http://www.voti.nl/hvu
Teacher electronics and informatics
 
Greetings Mentor, master of the PIC

The man solely responsible for me spending money and considerable time on
these little blighters

Paul
 
The man solely responsible for me spending money and considerable time on
these little blighters
With some succes I hope?


Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
Webshop for PICs and other electronics
http://www.voti.nl/hvu
Teacher electronics and informatics
 
Hi All,
With great success, thanks.

One was programmed to activate a modified video for surveillance work, when
a PIR was triggered it would record for 2 minutes and then shut down, wait
for the next trigger.

One was used to detect when a voltage line failed or started.

One was used to set my JX-3P synth to automaticaly not be in omni mode, but
only to receive on channel 1 ( MIDI )

Paul
 

Welcome to EDABoard.com

Sponsor

Back
Top