PDA

View Full Version : 16F877A with 20MHz XTAL not working?



ustredna
- 14th September 2006, 20:44
Please help me, i designed a one board width 16F877A and 20MHz xtal.
CPU not working.
code is designed with DEFINE OSC 20

4mhz xtal working perfect.
DEFINE OSC 4

why????

please help me.

16f877A - I/P - 20MHz (DEFINE OSC 20) - Don't work

Archilochus
- 14th September 2006, 20:47
Have you set the device configuration word (or 'fuse') to the appropriate value for the 20MHz osc?

Arch

b1arrk5
- 14th September 2006, 21:13
I had the same problem, I didn't set the option on the programmer to HS (High speed.) I used the MELabs programmer, just go under options and make sure the oscillator is set for HS. After that everything worked great. I'm assuming that you do have the correct capacitors on the crystal.

Jerry.

ustredna
- 14th September 2006, 21:26
i have 2x 22pF capacitor with XTAL.

precision
- 15th September 2006, 03:40
I also had the same problem, PIC16F877A I/P e3 sample from micrpchip,
i set config. bit in programmer "HS" , but working only up to 4 MHZ

b1arrk5
- 15th September 2006, 17:11
I found this helpful, from the Microchip website;
http://ww1.microchip.com/downloads/en/DeviceDoc/31002a.pdf
I hope it helps.

Jerry.

sebapostigo
- 13th March 2008, 20:58
a try all configurarion in hardware and software, other forum, say that using a command for set de fuses, but, not work, my configuration word is 2F4A, in de code write:

@ DEVICE HS_OSC
@ DEVICE WDT_OFF
@ DEVICE lvp_off
Define OSC 20

use other combination too:

@ DEVICE HS_OSC
@ DEVICE WDT_OFF
Define OSC 20

@ DEVICE HS_OSC
@ DEVICE lvp_off
Define OSC 20

@ DEVICE HS_OSC
Define OSC 20


with osciloscope, obtain sin wave in pins 14 and 13 at 20 +- 0.8 Mhz, for test, program pic whit this:

Prg:
PortA = %01010
PortB = %01010101

pause 500
hserout ["Prueba de envio 1",13]

PortA = %10101
PortB = %10101010

pause 500
hserout ["Prueba de envio 2",13," ",13]

goto prg

Archangel
- 13th March 2008, 22:18
Hi ustredna,
What everyone here is trying to explain, but not quite doing is this:
The PIC oscillator requires a bit more power to operate at speeds above 4mhz.
you set the program parameters to be correct in your code for the oscillator speed with your DEFINE OSC 20 statement, but you tell the programmer to enable the oscillator to use the high power setting with the config fuse, or by manualy selecting HS on the programmer's software, elsewise your Oscillator is not going to work.
JS

JD123
- 13th March 2008, 22:58
See this AN http://ww1.microchip.com/downloads/en/AppNotes/00826a.pdf

precision
- 14th March 2008, 03:41
you will have to edit your 16F877A.inc file as below.

NOLIST
ifdef PM_USED
LIST
include 'M16F87xA.INC' ; PM header
device pic16F877A, HS_osc, wdt_OFF, lvp_off, protect_ON , CP_ON
XALL
NOLIST
else
LIST
LIST p = 16F877A, r = dec, w = -302
INCLUDE "P16F877A.INC" ; MPASM Header
__config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

Your 16F877A will work on 20Mhz.

Archangel
- 14th March 2008, 04:13
you will have to edit your 16F877A.inc file as below.

NOLIST
ifdef PM_USED
LIST
include 'M16F87xA.INC' ; PM header
device pic16F877A, HS_osc, wdt_OFF, lvp_off, protect_ON , CP_ON
XALL
NOLIST
else
LIST
LIST p = 16F877A, r = dec, w = -302
INCLUDE "P16F877A.INC" ; MPASM Header
__config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

Your 16F877A will work on 20Mhz.
Hi ustredna,
The file mentioned above is included into your code automaticly when you compile using PBP and it contains "Default Settings" for your config statements, so if you do not include config statements in YOUR CODE it will default to the settings in this file. If you change the settings here it will DEFAULT to whatever you set here. Now for my opinion: I would not change the default to 20 mhz, I would instead simply put a semicolon at the beginning of the config statements so as to make the compiler overlook them as comments, and then include my own config statements in "MY CODE" every time.
JS
edit: Oh BTW, each PIC type has it's own file like this.

camolas
- 3rd May 2008, 01:02
Hi,

Ive the same problem, i thange the crystal, caps, code... and nothing (at 1st time when y bought it works on 20mhz).Then today i went to the store ans bougt one pic more, caps, clocks. The problem was on the the 1st pic!!! i was not very good only acepts 4mhz clocks.

:(

izzyblackout
- 19th August 2011, 15:04
you will have to edit your 16F877A.inc file as below.

NOLIST
ifdef PM_USED
LIST
include 'M16F87xA.INC' ; PM header
device pic16F877A, HS_osc, wdt_OFF, lvp_off, protect_ON , CP_ON
XALL
NOLIST
else
LIST
LIST p = 16F877A, r = dec, w = -302
INCLUDE "P16F877A.INC" ; MPASM Header
__config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

Your 16F877A will work on 20Mhz.

thx, this one works.