Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 28th December 2003, 05:49 PM   (permalink)
Experienced Member
brodin is on a distinguished road
Send a message via MSN to brodin
Default 12F675 Problem

I have a problem using my 12F675. I am using it with a external 4 MHz crystal.


My circuit:

PIN 1: +5V
PIN 2: Crystal / Capasitor(22pF) to GND
PIN 3: Crystal / Capasitor(22pF) to GND
PIN 8: GND


This is the CODE i am using:

Code:
DEVICE 12F675
CONFIG WDT_OFF, HS_OSC, PWRTE_ON, BODEN_OFF, MCLRE_OFF
DECLARE XTAL 4

OUTPUT GPIO.2

HIGH GPIO.2

Start:
  pause 500
  toggle GPIO.2
goto Start


stop
end

Pin 5 doesn't change state. It is high all the time!
I have also tried with a 20 MHz crystal. Same problem.

Do i have to setup any registers to get it work? What else can be the problem?
brodin is offline   Reply With Quote
Old 28th December 2003, 08:19 PM   (permalink)
Experienced Member
Rescyou is on a distinguished road
Default Crystal

Why would you want to use it with an 4mhz external crystal, it has an internal 4mhz one already? Is this picbasic you are using? I'm not familiar with this version of basic but have you programmed it so that the pic knows it has an external osc, though it appears that you have.

You may require a series resistor on osc2 depending on what kind of crystal you are using.

Maybe try:

OUTPUT GPIO.2

Start:

HIGH GPIO.2
pause 500
LOW GPIO.2
pause 500

goto Start

Try your code with the internal osc and see if that works, if it does then you know the external osc is misconfigured.

Resc.
Rescyou is offline   Reply With Quote
Old 28th December 2003, 10:57 PM   (permalink)
Experienced Member
brodin is on a distinguished road
Send a message via MSN to brodin
Default

I got it working with the 4MHz crystal now. I added the line ALL_DIGITAL = TRUE


But when i am using my 20 MHz crystal i am having problem again. It is VERY unstable. It may run for half a second then it stops, and then it runs a couple of seconds the not again.

What is the problem? You said something about a resistor. What value should is use then?
brodin is offline   Reply With Quote
Old 29th December 2003, 12:29 AM   (permalink)
Experienced Member
Rescyou is on a distinguished road
Default Resistor

I'm not sure what to use, I just looked on the 12f675 data sheet and it made mention of it.

Resc.
Rescyou is offline   Reply With Quote
Old 29th December 2003, 04:47 AM   (permalink)
Experienced Member
 
pike is on a distinguished road
Default

20Mhz is too fast for the PIC to. If it did work, all pauses and delays would be 5 times shorter in reality. also the program executes 5 times faster.
__________________
www.winpicprog.co.uk - Great PIC language tutorials.
pike is offline   Reply With Quote
Old 29th December 2003, 06:23 AM   (permalink)
Experienced Member
Rescyou is on a distinguished road
Default 20

I run my 12f675's a 20mhz all the time for led pwm and they work fine, I run the osc with built in caps though.

Most compilers I've worked with have a look at the mhz value and make changes so that commands like pause are at the same timing no matter the osc mhz.

Assembley language probably does not take this into consideration and the programmer must implement it and that's where the problem lies with respect to changing the osc mhz with asm code.

Resc.
Rescyou is offline   Reply With Quote
Old 29th December 2003, 09:17 AM   (permalink)
Experienced Member
brodin is on a distinguished road
Send a message via MSN to brodin
Default

Of cause i define the OSC in the code to 20 MHz. So pauses works just fine as ususal.

What are the crystals with built in cap named?
brodin is offline   Reply With Quote
Old 29th December 2003, 09:43 AM   (permalink)
Experienced Member
 
pike is on a distinguished road
Default

They're usually called resonators and they only have three pins. The middle pin connects to ground and the pins on the side is connected to osc1 and osc 2, separately.
__________________
www.winpicprog.co.uk - Great PIC language tutorials.
pike is offline   Reply With Quote
Old 29th December 2003, 12:31 PM   (permalink)
Experienced Member
brodin is on a distinguished road
Send a message via MSN to brodin
Default

OK, thanks!
brodin is offline   Reply With Quote
Old 29th December 2003, 02:50 PM   (permalink)
Experienced Member
Rescyou is on a distinguished road
Default Resonator

Here is a link for some resonator info:

http://www.piclist.com/techref/microchip/osc.htm

Resc.
Rescyou is offline   Reply With Quote
Old 29th December 2003, 09:40 PM   (permalink)
Experienced Member
brodin is on a distinguished road
Send a message via MSN to brodin
Default

Quote:
20Mhz is too fast for the PIC to. If it did work, all pauses and delays would be 5 times shorter in reality. also the program executes 5 times faster.
According to the data-sheet the maximum speed is 20MHz. I don't really need it now, but it would be good to know that it works.



I have another question about another thing. I have mostly worked with a basic compiler. I would like to learn some more assembler programming. Is there any good free tutorials, or e-books about assembler programming.
It have to be for newbies though =)[/code]
brodin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 01:11 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.