Crystals & Resonators

Thread Starter

Mazaag

Joined Oct 23, 2004
255
Hey guys,
I just purchased both a 3pin 4.00MHz Ceramic Resonator (CST4.00MGW) aswell as a 20MHz "Crystal for MPU Clock" (20.000m-hc49). I want to connect one of them up to my PIC16F877 as a clock. Now my question is as follows:

For the CERAMIC RESONATOR : DO i need additional circuitry ? if not , is there polarity on the resonator? ie: do i need to connect them in a specific way to my CLK in CLK out ? and is the middle pin the ground pin ?

Same for the Crystal , do i need any additonal capacitors or resistors ? is there polarity ?


One more question.
Lets say I output a logical 1 to one of the ports on my PIC, say RA0, does that mean the PIC gives a VOLTAGE at that pin ? or is it a current? and how much (voltage or current) ? what is the name of this parameter ?

thanks guys
 

Ron H

Joined Apr 14, 2005
7,063
That resonator is a hard part to find a datasheet for. I did find the following quote at this site:

For the clock, I got a ceramic resonator. I
recommend the ones with capacitors built in. I
got a 4MHz one (CST4.00MGW) and it works well.
The two sides of the resonator were connected to
the two OSC pins on the PIC (Pins 15 and 16). The
middle pin on the resonator was connected to GND.
 

Papabravo

Joined Feb 24, 2006
21,225
Originally posted by Mazaag@Mar 18 2006, 06:00 PM
Hey guys,
...
Same for the Crystal , do i need any additonal capacitors or resistors ? is there polarity ?
...
One more question.
Lets say I output a logical 1 to one of the ports on my PIC, say RA0, does that mean the PIC gives a VOLTAGE at that pin ? or is it a current? and how much (voltage or current) ? what is the name of this parameter ?

thanks guys
[post=15159]Quoted post[/post]​
Generally speaking when using a crystal there will be some small (15-30pf) capacitors from each lead of the crystal to ground. This provides some load in parallel with the crystal for the inverting amplifier inside the chip which goes from CLK_IN to CLK_OUT. The crystal manufacturer should specify on the data sheet the amount of load capacitence required.

A microprocessor, as well as most digital logic parts have four numbers which describe the capabilities of an output. An ideal specification would give a minimum value , a typical value, and a maximum value for each of those four numbers. Real data sheets will may not have all three numbers.

Vol (V-sub-O-L) : This is the voltage on the pin when the output is low.
Iol (I-sub-O-L) : This is the amount of current that the output can sink without Vol rising above its maximum value.

Voh (V-sub-O-H) This is the voltage on the pin when the output is high.
Ioh (I-sub-O-H) This is the amount of current that a pin can source without Voh dropping below its minimum value.

Let us take an example from the PIC16F873 that was the subject my PWM thread with damochi.

Go to page 156 of the PIC16F873 datasheet.
Parameter D0080 is Vol for the I/O Ports. It has a maximum value of 0.6 Volts
The box all the way to the right lists some conditions.
First condition is Vdd = 4.5 Volts, and the second is that Iol = 8.5 mA, and the third is that even over temperature Vol will not exceed 0.6V. So if Iol is less than 8.5 mA then Vol will probably be less than 0.6 Volts

On the same page look at parameter D0090, this is Voh for the I/O ports.
It says that the minimum value of Voh is (Vdd - 0.7) Volts. Again we have some conditions. Ioh is -3.0 mA, Vdd = 4.5 Volts, and the temperature is in {-40.0 to 85.0 degrees C}. The footnote says that negative currents mean that the pin is sourcing current. If the output tries to source more than 3.0 mA the voltage will dip below (Vdd - 0.7). If the output is sourcing only a small current then the output voltage will be very close to the rail.

One conclusion to draw from all this is that even though a PIC pin can sink about three times as much current as it can source, you can drive an LED or similar load either way.

Hope this helps
 

Thread Starter

Mazaag

Joined Oct 23, 2004
255
Originally posted by Papabravo@Mar 18 2006, 07:14 PM
Generally speaking when using a crystal there will be some small (15-30pf) capacitors from each lead of the crystal to ground. This provides some load in parallel with the crystal for the inverting amplifier inside the chip which goes from CLK_IN to CLK_OUT. The crystal manufacturer should specify on the data sheet the amount of load capacitence required.

A microprocessor, as well as most digital logic parts have four numbers which describe the capabilities of an output. An ideal specification would give a minimum value , a typical value, and a maximum value for each of those four numbers. Real data sheets will may not have all three numbers.

Vol (V-sub-O-L) : This is the voltage on the pin when the output is low.
Iol (I-sub-O-L) : This is the amount of current that the output can sink without Vol rising above its maximum value.

Voh (V-sub-O-H) This is the voltage on the pin when the output is high.
Ioh (I-sub-O-H) This is the amount of current that a pin can source without Voh dropping below its minimum value.

Let us take an example from the PIC16F873 that was the subject my PWM thread with damochi.

Go to page 156 of the PIC16F873 datasheet.
Parameter D0080 is Vol for the I/O Ports. It has a maximum value of 0.6 Volts
The box all the way to the right lists some conditions.
First condition is Vdd = 4.5 Volts, and the second is that Iol = 8.5 mA, and the third is that even over temperature Vol will not exceed 0.6V. So if Iol is less than 8.5 mA then Vol will probably be less than 0.6 Volts

On the same page look at parameter D0090, this is Voh for the I/O ports.
It says that the minimum value of Voh is (Vdd - 0.7) Volts. Again we have some conditions. Ioh is -3.0 mA, Vdd = 4.5 Volts, and the temperature is in {-40.0 to 85.0 degrees C}. The footnote says that negative currents mean that the pin is sourcing current. If the output tries to source more than 3.0 mA the voltage will dip below (Vdd - 0.7). If the output is sourcing only a small current then the output voltage will be very close to the rail.

One conclusion to draw from all this is that even though a PIC pin can sink about three times as much current as it can source, you can drive an LED or similar load either way.

Hope this helps
[post=15167]Quoted post[/post]​

I'm not quite sure I know what you mean by sourcing and sinking. I'll do some reading and try to figure it out.

Okay , so here's the deal.
I wrote my little program in assembly for my PIC on MPLAB. Its a very simple and basic program. It just sends an output to RA0 and RA1 of PORTA. Thats all.

Rich (BB code):
main

bcf STATUS,RP1   ;
bsf STATUS,RP0   ; RP1:RP0 = 01 Switch To Bank 1

movlw b'111100' ; Set RA0 and RA1 to output
movwf TRISA 

bcf STATUS,RP1
bcf STATUS,RP0   ; RP1:RP0 = 00 Switch To Bank 0

movlw b'000011'
movfw PORTA


end
What I want to do now is debug it and simulate it. Could someone run me through the simple steps of what to use to be able to simulate this program and monitor the register values?
Thanks
 

Papabravo

Joined Feb 24, 2006
21,225
In very simple terms:
1. A current sourcing transistor(BJT or FET) is connected between the power supply and the load. In most cases the other end of the load is connected to ground.
2. A current sinking transistor(BJT or FET) is connected between the load and Ground. In most cases the other end of the load is connected to the positive supply.

It has been some time since I used MPLAB, and I'll check on it for you. There are three basic steps.
1. Crate a project. There is a dropdown menu or a hot button for this purpose. This will pick the processor that you are using and name the source file with the program
2. Build the project. This will invoke the assembler and the linker.
3. Debug the project. This is where you will choose the simulator rather than downloading the output file into the Flash memory.

What version of MPLAB do you have? I'm still using Version 7.1 which is about 1 year old.
 

Papabravo

Joined Feb 24, 2006
21,225
Originally posted by Mazaag@Mar 18 2006, 08:28 PM
What I want to do now is debug it and simulate it. Could someone run me through the simple steps of what to use to be able to simulate this program and monitor the register values?
[post=15170]Quoted post[/post]​
Steps to simulate a PIC program with MPLAB
1. Launch MPLAB

2. Invoke the Project Wizard and answer all thw questions
Project | Project Wizard
Next
Step 1 Select a device
Select your device from the drop down list
Next
Step 2 Select a language toolsuite
Select Microchip MPASM toolsuite
Next
Step 3 Name your project
enter name and directory location
Next
Step 4 Add any existing files to your project
Select you source file and hit the Add button
Next
Finish

3. Project | Build All OR Control + F10

4. Debugger | Select Tool -> MPLAB SIM

5. View | Disassembly Listing

6. View | Registers

The Run/Step commands should be available on the main tool bar. Look for a button which has an arrow pointing into a pair of curly braces. This will single step the program and highlight the most recently changed registers in RED.
 
Top