16F877A isn't working with External Oscillator (HI-TECH C)

Microcontroller Topics
Post Reply
Max
Sergeant
Sergeant
Posts: 17
Joined: Tue Jul 21, 2009 3:31 pm

16F877A isn't working with External Oscillator (HI-TECH C)

Post by Max » Sun Apr 17, 2011 12:31 pm

Hi guys

I designed a small circuit with Microchip PIC16F877A micro. Non of the programs compiled with HI-TECH C compiler worked on the unit. I used the same programmer for several other systems. There is not much difference in this circuitry other than the 8MHz crystal oscillator I used. Even a small program to make a pin high doesn't work.

Can you think of a solution please?
User avatar
Shane
Captain
Captain
Posts: 226
Joined: Sun Jul 19, 2009 9:59 pm
Location: Jönköping, Sweden

Re: 16F877A isn't working with External Oscillator (HI-TECH C)

Post by Shane » Sun Apr 17, 2011 12:38 pm

You would need to set the oscillator at compile time. For 8MHz, you need to set to HS mode. Refer 12.2 section on the datasheet (Page 123).
12.2 Oscillator Configurations
12.2.1 OSCILLATOR TYPES
The PIC16F87X can be operated in four different oscillator
modes. The user can program two configuration
bits (FOSC1 and FOSC0) to select one of these four
modes:
• LP Low Power Crystal
• XT Crystal/Resonator
• HS High Speed Crystal/Resonator
• RC Resistor/Capacitor

XT
455 kHz
2.0 MHz
4.0 MHz

HS
8.0 MHz
16.0 MHz
To do this on HI_TECH C, add the following line before main.

Code: Select all

__CONFIG( HS & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
Post Reply

Return to “Microcontrollers”