View previous topic :: View next topic |
Author |
Message |
mmc01
Joined: 16 Jun 2010 Posts: 31
|
PIC16F716 LED Blink not work. |
Posted: Mon Aug 25, 2014 2:40 am |
|
|
I try to make easy LED blink with PIC but LED not blink. First I use XTAL 25MHz and it not work so I change to 16MHz It's not work Now I use 4Mhz but it's not work too.
I use 16F72 and I think it lose So I change to 16F648 but LED not blink Now I use 16F716 it's not blink too .
Pin MCLR/VPP I connect with R1k to 5V but It's not work so I pull out R and connect direct to 5V it's not work. Now I connect with R4.7 to 5V it also not work. I think my PIC not lose I can wite ,read and erase program from my PIC. I measure output pin A1 it alway 1V and not blink. I don't know why LED not blink.
Code: | #include <16F716.h>
#use delay(clock=4000000)
#fuses XT,BROWNOUT,NOWDT,NOPROTECT
void main()
{
while(1){
output_high(PIN_A1);
delay_ms(500);
output_low(PIN_A1);
delay_ms(500);
}
} |
Last edited by mmc01 on Tue Aug 26, 2014 1:37 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Aug 25, 2014 2:54 am |
|
|
Of course it won't.....
Look at your 'design'. Remember the little groups of six pins on each leg of the IC are all connected together. You have the two clock pins, connecting to the crystal (good), but then connecting to both legs of the capacitors, and to ground. Duh. The oscillator is shorted out, so has no hope of working....
Test with a voltmeter. Pins 15 and 16 of the chip are both shorted to ground. |
|
|
mmc01
Joined: 16 Jun 2010 Posts: 31
|
|
Posted: Wed Aug 27, 2014 3:06 am |
|
|
I measure pin 15, 16 it's 0.01 mV . I don't know why LED not blink. May be 16F716 not use MCLR . How to use 16F716 LED blink |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Wed Aug 27, 2014 4:15 am |
|
|
Reread Ttelmah's comment. So what you measure are correct. Your pins are shorted to ground. Remove the short and it might start working.
Regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 27, 2014 11:48 am |
|
|
This photo shows the correct wiring for the crystal circuit:
http://www.voti.nl/blink/pics/bb-870-big.jpg
Note how each 22pf capacitor is connected to a crystal pin and the
other lead jumps over to connect to the ground rail (which is the blue line).
The black wire is a ground wire. It's not part of the crystal circuit.
The key thing to understand is that on the breadboard, each vertical strip
of 5 holes is connected together internally.
Here is a more spread-out way of doing the crystal circuit:
http://nevcx.files.wordpress.com/2013/08/arduinoisp02_bb2.png
It's a different microcontroller, but the idea is the same.
Notice how each oscillator pin on the microcontroller goes over to
the crystal. One side of each capacitor goes to the crystal, and the
other side of the cap goes to ground. This spread-out crystal layout
is not ideal, but it probably will still work. If you cut your two capacitor
leads too short and you don't have more caps, then you may have to
do it this way. |
|
|
mmc01
Joined: 16 Jun 2010 Posts: 31
|
|
Posted: Wed Aug 27, 2014 8:34 pm |
|
|
Thank you very much. |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Mon Nov 24, 2014 8:00 am |
|
|
I do same thing but still does not work.
This my code
Code: |
#include <16F716.h>
#FUSES NOWDT, NOBROWNOUT, NOPROTECT
#use delay(Crystal=4000000)
#Define IN1 PIN_B0
#Define IN2 PIN_B1
#Define OUT1 PIN_A0
#Define OUT2 PIN_A1
VOID main ()
{
port_B_pullups (0xFF) ;
WHILE (TRUE)
{
IF (!input (IN1))
{
Output_high (OUT1);
Output_low (OUT2);
}
IF (!input (IN2))
{
Output_high (OUT2);
Output_low (OUT1);
}
}
}
|
When press down button (IN1), the LED ON (OUT1).
When press Up button(IN1), the LED OFF (OUT1).
Why that?
If true:
Press button (IN1), the LED (OUT1) is ON and LED (OUT2) is OFF.
Press button (IN2), the LED (OUT1) is OFF and LED (OUT2) is ON.
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Nov 24, 2014 8:24 am |
|
|
What is on pin4 of your chip?.... |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Nov 24, 2014 8:35 am |
|
|
Hi,
It sure looks like the anodes (+) of your LEDs are connected to the GND rail? The cathode (-) connection of the LED is adjacent to the 'flat' spot on the package, and this pin needs to be connected to GND. If mis-wired, your LEDs are never going to light!
Forget the switches for a moment. Can you make an LED blink at a predictable rate, say 1 sec. On and 1 sec. Off??
When you do get around to testing your switches, it's customary to use a pull-up on the input pin, with the switch momentarily connecting the input to GND. Alternately, you can use a pull-down on the input pin, with the switch momentarily connecting the input to Vcc.
John |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Mon Nov 24, 2014 8:53 am |
|
|
Ttelmah wrote: | What is on pin4 of your chip?.... |
Pin4 not connect. |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Mon Nov 24, 2014 9:09 am |
|
|
ezflyr wrote: | Hi,
It sure looks like the anodes (+) of your LEDs are connected to the GND rail? The cathode (-) connection of the LED is adjacent to the 'flat' spot on the package, and this pin needs to be connected to GND. If mis-wired, your LEDs are never going to light!
|
All LED are light, but they are off when button is open.
ezflyr wrote: |
Forget the switches for a moment. Can you make an LED blink at a predictable rate, say 1 sec. On and 1 sec. Off??
|
I'm try
Code: |
#include <16F716.h>
#FUSES NOWDT, NOBROWNOUT, NOPROTECT
#use delay(Crystal=4000000)
VOID main ()
{
WHILE (TRUE)
{
Output_high (PIN_A0);
delay_ms (1000);
Output_low (PIN_A0);
delay_ms (1000);
}
}
|
It not work.
ezflyr wrote: |
When you do get around to testing your switches, it's customary to use a pull-up on the input pin, with the switch momentarily connecting the input to GND. Alternately, you can use a pull-down on the input pin, with the switch momentarily connecting the input to Vcc.
John |
Set Pull_Ups then connect to GND same Set Pull_Down then connect to VCC. It not work.
Sorry, I'm not fluent in english. (google help me) |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Mon Nov 24, 2014 9:14 am |
|
|
Ttelmah wrote: | What is on pin4 of your chip?.... |
Wow, thank you very much.
Connect Pin4 to VCC with 10k. OK. |
|
|
|