Author Topic: PIC16F54 External clock  (Read 1020 times)

0 Members and 1 Guest are viewing this topic.

Offline AztlanpzTopic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: us
PIC16F54 External clock
« on: November 14, 2019, 10:14:56 am »
I am having a hard time getting the PIC16F54 to run form an external clock.  I am using a function generator( SIGLENT’s SDG2000X) to generate a TTL square wave at  2.4 MHz and i am using pin16(OSC1/CLKIN) as the clock pin. Is it passable  to run the PIC16F54 with an external Clock?  |O



Thank you

Aztlan
 

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2820
  • Country: us
Re: PIC16F54 External clock
« Reply #1 on: November 14, 2019, 12:01:28 pm »
What are your configuration bits?
I always use HS mode when using an external clock.  See Figure 4-2 in the datasheet.

Also, do you have MCLR- (pin 4) pulled high?

Code: [Select]
// PIC16F54 Configuration Bit Settings

// 'C' source line config statements

// CONFIG
#pragma config OSC = HS         // Oscillator selection bits (HS oscillator)
#pragma config WDT = OFF        // Watchdog timer enable bit (WDT disabled)
#pragma config CP = OFF         // Code protection bit (Code protection off)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

« Last Edit: November 14, 2019, 12:13:39 pm by MarkF »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13308
Re: PIC16F54 External clock
« Reply #2 on: November 14, 2019, 12:09:20 pm »
@Aztlanpz,
Yes, but it wont run that way 'fresh out the box'.  You'll need to set the CONFIG (aka: 'fuses') for XT or HS oscillator mode* (as MarkF has already mentioned), and you'll need to put a clean logic level signal with fast edges free from ringing on the OSC1 pin.  There's a good clue to what it needs in the datasheet, figs 4-2 and 4-3 which both show a buffer between the clock source and the OSC1 pin. Additionally fig. 4-3 uses a 74AS04, which suggests that LS TTL logic may not be fast enough.   

If you are using an off-board clock source, you'll need to terminate the cable from it to suppress ringing and reflections.  Based on the datasheet figs 4-2 and 4-3, I'd then recommend a 74AC or similar high speed CMOS Schmidt input gate, as close as possible to the PIC, to clean up the edges.  Good decoupling will be essential.

* The difference between XT and HS mode is the gain the internal Pierce oscillator amplifier between OSC1 and OSC2 is configured for. As you aren't using OSC2, either should work equally well.  RC oscillator mode with an external signal source is disastrous, see fig. 4-5, the internal N-MOSFET discharge transistor shorts the input almost as soon as it goes high!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf