Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with simple LED blinking program for pic16f628

Status
Not open for further replies.

scgoo

Newbie level 4
Joined
Mar 6, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
malacca
Activity points
1,352
i'm the newbie for PIC programming...
i'm using pic16f628. i now trying the simple program on the pic .. but it seems doesnt work. i'm using 20MHz cyrstal and two 3.3uF capacitor.

the LED is on , but it doesnt blink.. any problem with the crystal using??
this is my code

@ DEVICE pic16F628, WDT_OFF
@ DEVICE pic16F628, PWRT_OFF
@ DEVICE pic16F628, MCLR_OFF
@ DEVICE pic16F628, BOD_OFF
@ DEVICE pic16F628, LVP_OFF
@ DEVICE pic16F628, CPD_OFF
@ DEVICE PIC16F628, HS_OSC
@ DEVICE pic16F628, PROTECT_OFF

define OSC 20

CMCON = 7
VRCON = 0
TRISA = %11111101

loop:
PORTA.1 = 1
pause 500

PORTA.1 = 0
pause 500


goto loop


end
 

pic16f628 HELP!!

Hi scg00,

I'm used to writing assembly code in PIC.
Can you explain what pause 500 does?
If it's us then led may seem to be on. Check dc voltage on pin using a multimeter. If it's vcc/2 you've got it.

Giri
 

Re: pic16f628 HELP!!

For the oscillator, you should use very low capacitance as low as 15pF to 22pF, see datasheet for capacitors values suitable to 20MHz crystals.

With 3.3uF capacitors, the oscillator absolutelly will not work.
 

Re: pic16f628 HELP!!

Not sure which compiler you are using, but I know the 628 also has an internal osc, and the following may or may not, be relevant:
ER_IO External resistor osc
INTRC_IO Internal RC Osc, no CLKOUT
ER External resistor osc, with CLKOUT
INTRC Internal RC Osc
Also the two previous posters offer some good advice. If your delay is only 500 micro seconds, you probably won't see the flash, and if you are using 3.3u caps, they are way to big. I agree 15-30p as the data sheet says. Why not try running on the internal osc, just to get it working?
Best wishes,
Robert
 

Re: pic16f628 HELP!!

to vsgiri,
pause 500 ' pause 0.5 sec


after i change the capacitor to 22pF, its work.!!
or i change the the crystal to 4MHz with 33pF capacitors, it also work...
and i also change to
pause 5000 'pause 5sec

then i just can notice the blink of the LED



thanks vsgiri
thanks rkodaira
thanks Beebop

thank you very much!!!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top