![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | 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? |
| | |
| | (permalink) |
| Experienced Member | 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. |
| | |
| | (permalink) |
| Experienced Member | 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? |
| | |
| | (permalink) |
| Experienced Member | I'm not sure what to use, I just looked on the 12f675 data sheet and it made mention of it. Resc. |
| | |
| | (permalink) |
| Experienced Member | 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. |
| | |
| | (permalink) |
| Experienced Member | 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. |
| | |
| | (permalink) |
| Experienced Member | 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? |
| | |
| | (permalink) |
| Experienced Member | 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. |
| | |
| | (permalink) |
| Experienced Member | OK, thanks! |
| | |
| | (permalink) |
| Experienced Member | |
| | |
| | (permalink) | |
| Experienced Member | Quote:
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] | |
| | |