View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 06, 2022 8:44 am |
|
|
I told him that. But he said he did it like I said. That's why I asked
him to post his LED blinking code. |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 10:55 am |
|
|
PCM programmer wrote: | Post your LED blinking program.
If possible, post a link to a photo of your test board. It should be
a close-up photo so we can see all the connections. |
Answering to your request, here is a picture of my breadboard, I hope it is clear because since I'm using dupont jumper wires which are kinda long they like popup and it becomes a mess at some point...
Disregard the two USB data wires to run out of the picture, the thing is that I have 4 breadboards put together and I was making another circuit for USB with a PIC18F4550 on the first breadboard at the very left and I made the blinker ciruit on the rightmost breadboard.
I'm taking 5V from an USB port on my computer but I can switch to a regular dc transformer but I think it shouldn't make a difference.
Here is my code for the blinker
Code: |
#include <TesterMultiplexor.h>
#use fast_io(B)
void dibujarNumero(int numero) {
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4);
switch (numero) {
case 1:
output_high(PIN_B4);
break;
case 2:
output_high(PIN_B3);
break;
case 3:
output_high(PIN_B4);
output_high(PIN_B3);
break;
case 4:
output_high(PIN_B2);
break;
case 5:
output_high(PIN_B2);
output_high(PIN_B4);
break;
case 6:
output_high(PIN_B3);
output_high(PIN_B2);
break;
case 7:
output_high(PIN_B4);
output_high(PIN_B3);
output_high(PIN_B2);
break;
case 8:
output_high(PIN_B1);
break;
}
//output_b(0);
delay_ms(200);
//output_b(numero);
}
void main() {
//setup_adc_ports(AN0);
//set_analog_pins(PIN_A0, PIN_A1);
//setup_adc(ADC_CLOCK_INTERNAL);
set_tris_a(0xFF); //Entrada
set_tris_b(0x00); //Salida
set_tris_c(0x00); //Salida
set_tris_d(0xFF); //Entrada
int contador = 0;
int presionado = 0;
//Empiezo con el display en 0
/*output_low(PIN_D1);
output_low(PIN_D2);
output_low(PIN_D3);
output_low(PIN_D4);*/
//output_b(0);
//dibujarNumero(8);
int encendido = 0;
while(TRUE){
/*mandarSalidaAlMux(contador);
if (verificoMux(contador)==1) {
output_high(PIN_D0);
} else {
output_low(PIN_D0);
}*/
//output_b(0xFF);
/*dibujarNumero(contador);
contador++;
contador = contador % 9;
if (input(PIN_A0) && presionado == 0) { //Si se clickeó el pulsador entonces avanzo una posición
presionado = 1; //Seteo el flag para que solo me tome una presión del pulsador y espere a que lo suelte para volver a avanzar.
contador+=1;
if (contador > 8) {
contador = 0;
}
dibujarNumero(contador);
}
if (!input(PIN_A0)) { //Si se soltó el pulsador reseteo el flag para poder volver a presionarlo
presionado = 0;
}*/
if (encendido==0) {
output_high(PIN_B7);
encendido = 1;
} else {
output_low(PIN_B7);
encendido = 0;
}
delay_ms(500);
//TODO: User Code
}
}
|
And the header file
Code: |
#include <16F877A.h>
#fuses HS, NOWDT, BROWNOUT, PUT, NOLVP, NOPROTECT
#use delay(crystal=8MHz)
|
As you can see I used the same file, I just commented the previous logic for the 7 segment display and implemented a little code to turn on and off a led every 500ms... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 06, 2022 1:15 pm |
|
|
Your LED blinking program is too complicated. Use this one:
Code: | #include <16F877A.h>
#fuses HS, NOWDT, BROWNOUT, PUT, NOLVP, NOPROTECT
#use delay(clock=8MHz)
//====================================
void main()
{
while(TRUE)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
Also, I don't see a series resistor on your LED. You need one.
Here's an example. Note that the cathode goes to ground.
The anode is connected to the resistor.
Code: |
pin 330 ohms LED
B0 -----/\/\/\/------->|----
|
|
----- Ground
---
-
|
I changed it to use Pin B0. You're using pin B7 in your photo.
That's a programming pin. I never use programming pins for
user circuits if at all possible. Circuits on the programming pins
can prevent ICSP programming. However, I suspect you are
programming the PIC in a socket programmer, and are not using ICSP. |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 1:46 pm |
|
|
PCM programmer you are right, I use a PICkit 3 clone with a Zif socket to program my pic, and I use it on standalone mode so I use the PICkit 3 Programmer app instead of MPLAB.
I will make the changes and let you know if it works after all.
Thanks for your time. |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 2:01 pm |
|
|
I just tried connecting the led to the B0 pin with a 330 ohm resistor and using the code provided and I'm afraid it still doesn't work.
I'm starting to consider that my PIC is just dead, the weird thing is that PICkit 3 recognizes it and can both read and write without issues and yet the God damn thing appears to not want to work.
Here is how my bread board is looking now...
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 06, 2022 3:41 pm |
|
|
Have you checked your Vdd voltage with a meter, to see if it's really
there ?
It would be nice if you had a PIC with an internal oscillator, such as
at least, the 16F887. Then you are not dependent on the external
oscillator circuit working. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Wed Apr 06, 2022 3:54 pm |
|
|
It looks like there are black wires going to Vdd and Vss on pins 11&12.
Is it possible both of those are ground rather than 5V and Gnd? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 3:58 pm |
|
|
I did check between VDD and GND and my meter shows about 4.8v (approx) I guess that i wouldn't matter those 0.2v down that I have...
I'm afraid I only have 3 PIC16F877A (one of em seems to be dead for sure as I just can't write on it, it claims that the program address at 0002 fails so I guess that the program memory is screwed) and 2 PIC18F4550.
And also I don't own an oscilloscope so I Just can count on my trusty multimeter (Proskit MT-1710)
I wonder if the crystal may have broken down... I have one 4Mhz, one 8Mhz, one 20Mhz, five 18Mhz and five 40Mhz crystals...
I really appreciate the fact that you are taking your time to help a complete stranger (who is also kinda noob in the business) |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 4:04 pm |
|
|
dyeatman wrote: | It looks like there are black wires going to Vdd and Vss on pins 11&12.
Is it possible both of those are ground rather than 5V and Gnd? |
I must admit that my choice of colors is not the most appropriate but I double checked the connections and it is not shorted, the wire that goes to VDD is dark purple, anyway I just replaced em for black and red wires. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 5:19 pm |
|
|
PCM programmer, I rechecked all the connections and I realized I had the PIC displaced one pin, now it is properly placed on my bread board and the led lights on but wont blink, just stays on. I tried with my 4Mhz crystal and my 8Mhz crystal. I also tested with the 18F4550 (of course I changed the include on the code to include the proper driver).
The led just stays on... |
|
|
manusoftar
Joined: 19 Mar 2022 Posts: 46
|
|
Posted: Wed Apr 06, 2022 7:33 pm |
|
|
I just realized that if I unplug GND from my PIC, the led stays on which makes me believe that somehow the pic is just shorting B0 to VDD because, if I'm not wrong, it wouldn't run without GND connected to it's pins...
I also tried another PIC16F877A that I have and also a PIC18F4550, I also tried changing the 22pf caps on the crystal and also tried with a 4Mhz crystal and an 18Mhz crystal in case my 8Mhz crystal was dead for some reason but nothing seems to work...
At this point I don't know if my PIC's are faulty, if my crystals are faulty, if my bread board is faulty, if the power I'm getting from the usb port is just not enough to make the PIC work (it did work on a different circuit on the 18F4550 but I was making a HID device with that PIC and perhaps the computer only rises the voltage on the usb por if it detects an actual device plugged (I mean on the data lines)).
If anyone has any other idea of what else may be causing this I will greatly appreciate some hints.
Thanks.- |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Wed Apr 06, 2022 8:37 pm |
|
|
1. Verify your connections 2 or 3 times. Don't assume anything, count pins, verify connections without power applied. Best to use a multimeter to ensure continuity where there should be continuity and opens where there shouldn't be continuity. Verify against chapter 2 of the PIC's data sheet. The minimum connections are always spelled out in chapter 2.
2. You're using a solderless breadboard to experiment. They're famous for something and it's not their awesome high frequency performance. High frequency circuits require exquisite attention to parasitics, particularly capacitance and inductance. A solderless breadboard is okay for low frequency (a few hundred kHz would be, to me, pushing things), but not higher. Why? Their construction leads to very high parasitic capacitance.
What's connected from each crystal leg to ground? Capacitors, right? Their value? A "few" pF.
What happens if a crystal circuit "sees" too much capacitance? From experience, I can assure you that it will fail to oscillate at all.
Remove your crystal caps entirely. The clock might not be accurate, but it will have a much higher likelihood of oscillating vs what you have now. If it still doesn't oscillate, try taking a spare wire, with one end connected to your Vcc (I think you said it was 5V), and gently touch the other end to one of the PIC's crystal/oscillator pins. This might "kick start" oscillations.
Good luck. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Apr 07, 2022 2:14 am |
|
|
Though the older PIC's are very rugged, 'just displaced one pin', means he
has been feeding the supply very much into the wrong place. He may have
just destroyed the PIC.
This is why we always repeat 'check the connections carefully'. It is just
like the old carpentry adage 'measure twice cut once'.
If it was displaced 'one pin down', then the supply would have been feeding
into B0, and 5v on the ground pins. Possibly B0 (and E2) are the damaged
pins. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Thu Apr 07, 2022 8:25 am |
|
|
Quote: |
I use a PICkit 3 clone with a Zif socket to program my pic, and I use it on standalone mode so I use the PICkit 3 Programmer app instead of MPLAB. |
Not using ICSP is in my opinion a colossal waste of time. You need to remove the PIC from the breadboard for every change in program. Through all the jumper wires. And put it back, of course. Second, you rob yourself of the ability to debug, see if you can even reach reset, step through your code, reach a breakpoint. Mplab also tells you the voltages. |
|
|
|