CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Clock problem on 16f84

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Wridmuld



Joined: 02 Apr 2004
Posts: 15

View user's profile Send private message Send e-mail

Clock problem on 16f84
PostPosted: Thu Sep 30, 2004 6:05 am     Reply with quote

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

View user's profile Send private message Send e-mail

comment
PostPosted: Thu Sep 30, 2004 6:29 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Sep 30, 2004 6:49 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 30, 2004 7:02 am     Reply with quote

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
PostPosted: Thu Sep 30, 2004 7:08 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 30, 2004 8:06 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 30, 2004 8:53 am     Reply with quote

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







PostPosted: Thu Sep 30, 2004 9:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 30, 2004 10:33 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 30, 2004 11:12 am     Reply with quote

Erm...hrm.

This was a little embarassing actually. Now it works! Embarassed


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

View user's profile Send private message

PostPosted: Thu Sep 30, 2004 12:15 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group