View previous topic :: View next topic |
Author |
Message |
Wridmuld
Joined: 02 Apr 2004 Posts: 15
|
Clock problem on 16f84 |
Posted: Thu Sep 30, 2004 6:05 am |
|
|
Hi.
I have written a short and easy part of code just to test if my 16f84 is alive. Three diodes blinking...
However, it's not alive.
Now I measured the voltage on the clocks (clkin and clkout) and they are both 0V.
How does this come? Anybody got any suggestions? |
|
|
Wridmuld
Joined: 02 Apr 2004 Posts: 15
|
comment |
Posted: Thu Sep 30, 2004 6:29 am |
|
|
Erm - I might add that I'm not totally new to this. I have done a few projects on the 16f84. It's just that I have never before experienced that nothing happens at all.
I have tried with 3 different 16f84's, and I just can't believe they are all dead. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Thu Sep 30, 2004 6:49 am |
|
|
Quote: | However, it's not alive.
Now I measured the voltage on the clocks (clkin and clkout) and they are both 0V.
How does this come? Anybody got any suggestions? |
If you used a multimeter to measure the voltage then you most likely stopped the oscillator with the load. Do a simple LED flash program or toggle a pin an use a logic probe. |
|
|
Wridmuld
Joined: 02 Apr 2004 Posts: 15
|
|
Posted: Thu Sep 30, 2004 7:02 am |
|
|
A simple LED flash program is just what I have made.
I have no logic probe. :(
It's just completely dead. |
|
|
Ttelmah Guest
|
Re: Clock problem on 16f84 |
Posted: Thu Sep 30, 2004 7:08 am |
|
|
Wridmuld wrote: | Hi.
I have written a short and easy part of code just to test if my 16f84 is alive. Three diodes blinking...
However, it's not alive.
Now I measured the voltage on the clocks (clkin and clkout) and they are both 0V.
How does this come? Anybody got any suggestions? |
Start by removing the chip. Apply power, and put a resistor of perhaps 4.7K between +5v, and the pin corresponding to 'clkout' on the chip socket. Test the voltage at clkout, with the meter. If it is still at 0v, then there is a short circuit to ground somewhere around this pin. Repeat this, but pull the 'clkin' pin high. Same applies.
Also check that MCLR is being pulled high (the oscillator won't start untill this is seen as a logic high). Check that 5v is actually on the supply pin.
I sounds as if you have a hardware problem proventing the chip from starting. Unfortunately, there are quite a few things this could be...
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 30, 2004 8:06 am |
|
|
Hi Wridmuld,
We would like to know a little more:
1) The #fuse configuration.
2) If you are using a Xtal, the value that has stamped on it.
3) The capacitor values involving in the oscillator circuit.
4) Did you test with another microcontroller ?
5) Post your test program.
Best wishes,
Humberto |
|
|
Wridmuld
Joined: 02 Apr 2004 Posts: 15
|
|
Posted: Thu Sep 30, 2004 8:53 am |
|
|
Here is my code:
#device PIC16F84
#use delay (clock=4000000)
#fuses xt, nowdt
#byte port_a=0x05
#byte port_b=0x06
main()
{
int readval_b;
int readval_a;
set_tris_a(0b00000011); //A0-A1 INPUTS, THE REST OUTPUTS
set_tris_b(0b00001111); //B0-B3 INPUTS, THE REST OUTPUTS
while (1);{
port_b = 0x10;
delay_ms(500);
port_b = 0x00;
delay_ms(500);
port_b = 0x10;
delay_ms(500);
port_b = 0x00;
delay_ms(500);
}
delay_ms(1);
while(1);
}
I'm not sure what Xtal means, but I got a crystal. It's a 4 Mhz crystal and it says 4.00 which stand for Mhz, of course.
The capacitors are built into the crystal, so there should be no problems with that. And it has worked before.
I have tried 3 16f84 now, and as I said before, I doubt that all 3 of them are broken.
I am not sure what all the fuses mean, tbh.
/Wridmuld |
|
|
jpa Guest
|
|
Posted: Thu Sep 30, 2004 9:38 am |
|
|
while (1); {
The ; should not be present. while(1); is an endless loop. The program nerver goes to the next instruction. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 30, 2004 10:33 am |
|
|
Hi Wridmuld,
That�s the way, posting your test source and complete info.
As jpa remarks, just take out the ; following the while
For an endles loop you can use
Code: |
do
{
...... your code
}while(1); // Here you need the ";"
|
or simply
Code: |
while(1)
{
..... your code
}
|
best wishes,
Humberto |
|
|
Wridmuld
Joined: 02 Apr 2004 Posts: 15
|
|
Posted: Thu Sep 30, 2004 11:12 am |
|
|
Erm...hrm.
This was a little embarassing actually. Now it works!
But a question still: the fuses - how are they to be used? How many fuses are there and what is the purpose of them? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 30, 2004 12:15 pm |
|
|
The compiler need to know about the hardware to set accordingly a special register named
Configuration Register, wich is accesable only during programming time.
The directive #fuses tell the compiler to set each bit of the referenced register.
In the 16F84 datasheet you will find all the info regarding this register and the meaning of each bit.
Following is another way to write your test:
Code: |
main()
{
set_tris_a(0b00000011); //A0-A1 INPUTS, THE REST OUTPUTS
set_tris_b(0b00001111); //B0-B3 INPUTS, THE REST OUTPUTS
while(1)
{
output_toggle(PIN_B7);
delay_ms(500);
}
}
|
Best wishes,
Humberto |
|
|
|