PDA

View Full Version : I can't even make an LED flash!



George
- 2nd April 2007, 00:24
I'm playing with a 16F628 and for some reason I'm having significant trouble, I'm running a 4MHz crystal with 15pF caps - am running crystal rather than INTRC as I'm wanting reliable serial comms - but in the interum I can't even flash an LED - can anyone please tell me where I'm going wrong? I know it'll be something stupid but stuffed if I can figure it!

Thanks

@ DEVICE PIC16F628, XT_OSC, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF, WDT_ON

DEFINE OSC 4

TRISA = %00000011
TRISB = %10000000

T1CON = %00000011
VRCON = 0 ' A/D Voltage reference disabled
CMCON = 7 'Disable comparitor
OPTION_REG = %01010111

PortA = 0
PortB = 0

start:

portb.2 = 1
pause 100
portb.2 = 0
pause 100
goto start

skimask
- 2nd April 2007, 03:45
You've got 16F628 defined. Would you by chance actually mean 16F628A?

George
- 2nd April 2007, 04:15
Nup, it's just a plain old 16f628, i thought i'd blown up the chip so I tried another and no luck either - the only thing diff that I don't normally do is use a crystal - I have a long time ago but not recently

Cheers

skimask
- 2nd April 2007, 04:21
Nup, it's just a plain old 16f628, i thought i'd blown up the chip so I tried another and no luck either - the only thing diff that I don't normally do is use a crystal - I have a long time ago but not recently

Cheers

Another (probably bad) idea, I know your MCLR is defined as off, have you tried a pullup on it anyways?
Voltage on Vdd?
Have you let it run for more than about 10 seconds? If the LEDs are flashing at about 10 second intervals, somehow it might be getting on the internal 37khz clock instead of your 4mhz clock.

Melanie
- 2nd April 2007, 07:25
You've got a great chip to play with as a starter... that's because you can run on INTERNAL OSCILLATOR and INTERNAL MCLR... that eliminates two sources of trouble for a newbie... all you have to do then is worry about putting 5v on the proper pin on the chip, and stuffing a correct program into it. Excuse me for mentioning it, and don't be offended, but you are connecting the LED the correct way around too?

Archangel
- 2nd April 2007, 07:31
I'm playing with a 16F628 and for some reason I'm having significant trouble, I'm running a 4MHz crystal with 15pF caps - am running crystal rather than INTRC as I'm wanting reliable serial comms - but in the interum I can't even flash an LED - can anyone please tell me where I'm going wrong? I know it'll be something stupid but stuffed if I can figure it!

Thanks

@ DEVICE PIC16F628, XT_OSC, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF, WDT_ON

DEFINE OSC 4

TRISA = %00000011
TRISB = %10000000

T1CON = %00000011
VRCON = 0 ' A/D Voltage reference disabled
CMCON = 7 'Disable comparitor
OPTION_REG = %01010111

PortA = 0
PortB = 0

start:

portb.2 = 1
pause 100
portb.2 = 0
pause 100
goto start
Data sheet says to add @ DEVICE PIC16F628, PWRT_ON whenever BOD is enabled
Also: I do not believe this chip has A/D converters so VRCON is likely not valid but I am really unsure about that.

skimask
- 2nd April 2007, 13:49
How about the prototyping board itself? We've had some discussion here lately about how badly those things will treat you over time, connections not working, intermittent connections, etc. I've started replacing all of mine (got tired of messing with bad connections).
Have you tried putting the chip at the other end of the board or anything like that?

Archangel
- 2nd April 2007, 20:11
How about the prototyping board itself? We've had some discussion here lately about how badly those things will treat you over time, connections not working, intermittent connections, etc. I've started replacing all of mine (got tired of messing with bad connections).
Have you tried putting the chip at the other end of the board or anything like that?
Very good point! I just bought 4 replacements last month.

George
- 2nd April 2007, 22:15
Thanks for your input so far - but still nothing! The LEDs r the right way around, all the pins metered up ok - I might try the chip on INTRC to see what happens - will let you know how i get on, cheers

George
- 2nd April 2007, 22:33
Got it figured! For some reason the thing won't run at under 4.2V I've been trying to run it at 3.0V - I might revert to the 628A as it's better at lower power - on saying that the datasheet for the 628 does say it will run at 3.0V Thanks for your time everyone, I should have bumped the voltage to 5 much earlier. Good suggestion too skimask about the prototype boards I've had trouble with mine in the past but for some reason i still trust them - figure that one out!

skimask
- 2nd April 2007, 22:48
Got it figured! For some reason the thing won't run at under 4.2V I've been trying to run it at 3.0V - I might revert to the 628A as it's better at lower power - on saying that the datasheet for the 628 does say it will run at 3.0V Thanks for your time everyone, I should have bumped the voltage to 5 much earlier. Good suggestion too skimask about the prototype boards I've had trouble with mine in the past but for some reason i still trust them - figure that one out!

Well, the graph in the 16F628 datasheet does show that at 4mhz the minimum required voltage is 4.5v, even though the line goes up from 3.0 to 4.5v at that exact point.
So you have to wonder. Is it 4.5v @ 4mhz or 3.0v @ 4mhz minimum? Must be 4.5v...
And the datasheet also states that the minimum supply voltage is 3v, no matter the speed.
Maybe it'll run at 3.999999 mhz at 4.2v... after all, that's what the graph says! :D
Live and learn...
Happy PIC'ing...finally... :D

George
- 3rd April 2007, 00:42
Thanks for that - I didn't even think to look at the electrical specs I just noted the voltage range on the intro page (didn't help that most of the time I was looking at the 628A datasheet either)

Archangel
- 3rd April 2007, 06:39
@ DEVICE PIC16F628, XT_OSC, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF, WDT_ON

DEFINE OSC 4

TRISA = 000011
TRISB = 000000

T1CON = 000011
VRCON = 0 ' A/D Voltage reference disabled
CMCON = 7 'Disable comparitor
OPTION_REG = 010111

PortA = 0
PortB = 0

start:

portb.2 = 1
pause 100
portb.2 = 0
pause 100
goto start

Glad you got it working, might be BOD on causing it.