• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem solved!! have two problems 1-crystal osc, 2-__config

Status
Not open for further replies.

SnM

New Member
I have the pic 16f84A-04 micro controller. I built the "El Cheapo" programmer that came with my "Programming and Customizing PICmicro Microcontrollers" book.

After successfully burning the chip, I went to go test it. I connected all that i needed, and it wouldn't do anything. I tried to get a freq reading of the clock input from the crystal, but I couldn't get anything to read on my dmm. Is there some special way to measure frequency from a crystal?

I was wasting too much time getting nothing done and I started to try stuff. in the end, i just have one 6.8k resistor going into CLKIN. I know it is not the way it should be setup, but it sorta works now. i measured about 1Mhz at CLKIN now.

now that i have my temporary clock working (since the crystal didn't want to work) my program runs. :)

it only goes so far and then resets..... :(

I checked and double checked that I had WDT off. I simulated my program in MPLAB and I made sure I had this in my program from the start:

__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON

Just for the hell of it, I included a clrwdt line in my program and reburned the chip. Well now it works as desiged! It seems that for some reason, the config isn't being correctly written to the chip, and the wdt is being left enabled, even though I had to set to be off.

anyone have any ideas on how to get the config to be setup correctly?

also, do you think that since the config isn't being correctly setup, that the osc is not changing to an external crystal mode, and that is causeing my first problem?

Thanks in advance for any help.

Steve
 

low_byte

New Member
If you are using a external resistor for clock signal you need to set config to R/C which is for Resistor/Capacitor. Correct wiring for the clock circuits can be found in the documentation for the pic 16f84a from microchip's website.
 

ivancho

New Member
What type of crystal do you have....???? Make sure is a parallel and that you have the capacitors you need. There is a bigger science behind crystals that it is taken for granted, location in board, trace thickness, this and that.... But as long as you have a crystal running with its matching caps you should be good to go..... Most 4Mhz Crystals use a 18pF-33pF caps

Ivancho
 

tom2000

New Member
aaa

And eventho ivancho is an expert (like me of course) i can tell you this, you don't need to put any capacitors with the crystal, just hook up the crystal to CLKIN and CLKOUT and the circuit WILL work.

I never put those caps in my circuits
 

SnM

New Member
I bought just a regular (i think) 4.0 Mhz crystal from Jameco.

I am starting to belive that my crystal may be fine, I just cannot tell right now.

My problem seems to be with the configuration fuses. In my code, I have the watchdog timer set to OFF, but when I run my program, it continues to reset. I then added the clrwdt in my code, and now it works.

So, has anyone ever experienced or heard of the config fuses not getting programed correctly? It seems the rest of my program is correct.

Also, with the config fuses, isn't the default clock set to RC? If my config fuses are not getting set correctly, this could explain why my crystal isn't working with the chip, but the resistor is.

I am not able to look at my hex file right now, but I am going to check to see if it has the correct value for the fuses.

my config statment has:
code protect off
watchdog timer off
powerup timer on
XT oscillator

what should the value for that be?

If my hex file is correct, then the problem must be with the programer. but when I verify the burned chip, it says it is correct.

Thanks for the replys!!!

steve
 

ivancho

New Member
If you have an osciloscope you should be able to see a perfect sine wave at OSC2..... also have 20pF caps from each of the leads to ground.

Make sure also to have the MCLR pulled up high with a 4.7K resistance. And a decoupling capacitor 0.1uF near the 5V of the PIC....

And make sure your programmer works well... by having a blink program.... :wink:

Ivancho
 

Nigel Goodwin

Super Moderator
Most Helpful Member
SnM said:
Also, with the config fuses, isn't the default clock set to RC? If my config fuses are not getting set correctly, this could explain why my crystal isn't working with the chip, but the resistor is.

I am not able to look at my hex file right now, but I am going to check to see if it has the correct value for the fuses.

my config statment has:
code protect off
watchdog timer off
powerup timer on
XT oscillator

what should the value for that be?
The blank settings for the config fuses (after erasure) are WDT on, and RC oscillator ($3FFF) - so it looks like the fuses aren't been programmed.
The value you want is $3FF1 - PUT on and XT oscillator.

I haven't used your programmer, but are you sure it loads the config fuses from the HEX file (and are you sure they are assembled into the HEX file). Most programmers allow you to set the fuses within the program (certainly mine does!), after you've loaded the HEX file, and before you write to the chip.
 

SnM

New Member
my reset pin is pulled high via resistor, and i do have a cap near the supply.

my programmer is suppose to load the config. it doesn't have any option to change them when working in the programmer's program.

link to programmer site:

http://www.myke.com/elcheapo.htm

for he next software release, he does plan to "Add Configuration Fuse information/updating"

so maybe this will sovle my problem.......still haven't gotten an email back from him.

what do you use to program your pic's?

thanks,

steve
 

Nigel Goodwin

Super Moderator
Most Helpful Member
SnM said:
for he next software release, he does plan to "Add Configuration Fuse information/updating"

so maybe this will sovle my problem.......still haven't gotten an email back from him.

what do you use to program your pic's?
Myke Predko is a well known PIC 'expert', so he will probably get around to updating the software as he says.

I use my own software WinPicProg, it's highly configurable and could probably be set to work with the 'El Cheapo' programmer, you can download it at http://www.winpicprog.co.uk. You can select each input and output pin, and also if they are inverted or not - I also have manual toggle buttons so you can manually switch the lines and test with a meter.
 

SnM

New Member
thanks, i'll check it out.

I looked at my hex file and the line for the config fuses does not read 3FF1. More like 1Fxx, I forget the last two numbers now. Should the hex file read 3FF1, or does that value get changed to something else when the hex file is created?

Thanks,

steve
 

Nigel Goodwin

Super Moderator
Most Helpful Member
SnM said:
I looked at my hex file and the line for the config fuses does not read 3FF1. More like 1Fxx, I forget the last two numbers now. Should the hex file read 3FF1, or does that value get changed to something else when the hex file is created?
I've just created and saved a HEX file with the settings you require, this is the line it generated (I've spaced it out to it's seperate parts).

:02 400E 00 F13F 80

The F13F part is the actual config word, lower byte first - so 3FF1. The exact bytes can vary sometimes, most PIC's don't use all of the config bits, in my software I mask out any unallocated bits.
 

SnM

New Member
ok that is what i get. thanks for checking that for me.

so it looks like my programmer isn't programming it correctly. Won't be able to play around with it til thursday. I'll let you know the outcome!

thanks again!!!!!!

steve
 

SnM

New Member
I finally got it working, but not with the El Cheapo program.

I found this:

http://pp06.sourceforge.net

and it says it works with the El Cheapo hardware. Well, I tried it and it does work! It configures the config fuses for me!

So now my crystals work, and the watchdog timer doesn't reset my circuit anymore!!!!

Thanks for all the replys!

steve
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top