Log in

View Full Version : Newbie: Trying to blink a LED



JackPollack
- 24th February 2006, 16:28
Can someone help me get started. I have been trying to blink a LED using a 16F88 all morning without any success. What is wrong with my code?
Also is there ea way to define in code the chip being used so I dont have to select it each time from the drop-down? Thanks

@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF

LOW PORTB.1

LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP

paul borgmeier
- 25th February 2006, 09:15
JackPollack;

If you are working with PBP and the 16F88, I believe you need to put

OSCCON = $60

in your code to get the internal clock to run at 4MHz instead of 32kHz. If you do not put this in your code or if you do not tell PBP that you are running at 32kHz instead of the default 4MHz, then a Pause 1000 really equals =

1 second * 4,000,000/32,000 = 125 seconds!

Since you start with the portb.1 low, did you wait over two minutes to see if your light came on? Good Luck,

Paul Borgmeier
Salt Lake City, Utah
USA

JackPollack
- 25th February 2006, 17:19
Thanks for your reply.

I tried your suggestions, but no dice.

I am not seeing any logic levels on any of the outputs (they are all tri-stated). I have tried a different chip and the second one does the same.

Any other ideas?

paul borgmeier
- 26th February 2006, 07:02
JackPollack,

The following worked great on my 16F88:

;@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60
LOW PORTB.1
LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP

Notice that I commented out your fuse settings. I suggest picking them in the EPIC menu until you can get it running. My best guess is that INTRC_OSC_NOCLOCKOUT is not a correct setting but I could not verify. (I use MPASM exclusively and had the fuses set as shown in the attached.) As a check, I had pin 5 tied direct to ground, pin 14 tied direct to 5V, and had an LED between pin 7 and ground. Again, Good Luck

Oh, also see: http://www.picbasic.co.uk/forum/showthread.php?t=3155&highlight=16f88

Paul Borgmeier
Salt Lake City, Utah
USA

JackPollack
- 27th February 2006, 13:47
Thanks to all that posted. I found the problem was a bad PIC programmer.
Everything is working great now.

Thanks again.

jcleaver
- 28th March 2007, 15:37
JackPollack,

The following worked great on my 16F88:

;@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60
LOW PORTB.1
LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP

Notice that I commented out your fuse settings. I suggest picking them in the EPIC menu until you can get it running. My best guess is that INTRC_OSC_NOCLOCKOUT is not a correct setting but I could not verify. (I use MPASM exclusively and had the fuses set as shown in the attached.) As a check, I had pin 5 tied direct to ground, pin 14 tied direct to 5V, and had an LED between pin 7 and ground. Again, Good Luck

Oh, also see: http://www.picbasic.co.uk/forum/showthread.php?t=3155&highlight=16f88

Paul Borgmeier
Salt Lake City, Utah
USA

paul
i agree intrc_osc_noclockout
does not seem corect pic manual state it has 3 noclock setting
and three osc speed 4 - 8 and adj
cant seem to find the corect syntax though

paul borgmeier
- 29th March 2007, 06:31
it turns out "INTRC_OSC_NOCLKOUT" is correct (see m16f88.inc in your pbp folder). The code I posted in this thread worked for me - 1 second delays were one second. I did not use the @ device line (hence, it is commented out) but picked them from the menu in MPLAB (I do not use PM).

I am not sure what problems you are having or what you are asking here?