View previous topic :: View next topic |
Author |
Message |
jweller
Joined: 16 Oct 2006 Posts: 7
|
16lf88 trouble getting started |
Posted: Fri Feb 23, 2007 1:33 pm |
|
|
CCS version 3.249
I am trying to write a very basic program for a 16lf88 and am having no success at all. I'm sure I'm overlooking something simple.
Only thing I can think of at this point is that maybe in a newer compiler version, there is a different header file for the 16lf88 than there is for the 16f88. Microchip doesn't have separate datasheets for them so I figured it was ok to use the 16f88 header file.
this is my pic.h file
Code: |
#include <16F88.h>
#device adc=8
#FUSES NOWDT //NO Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, NO clkout
#FUSES NOPROTECT //Code not protected from reading
#FUSES PUT //Power Up Timer
#FUSES BROWNOUT //brownout reset
#FUSES NOLVP //no low voltage programming
#FUSES HS
#use delay(clock=8000000)
#define LED PIN_B0
|
and my pic.c file
Code: |
#include "pic.h"
void main()
{
setup_oscillator(OSC_8MHZ|OSC_INTRC);
while(1)
{
output_low(LED);
delay_ms(500);
output_high(LED);
delay_ms(500);
}
}
|
I'm probing pin b0 and it just sits at ground. It never goes high. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 23, 2007 1:41 pm |
|
|
The topic title says you're using the LF version of the PIC. That implies
that you may be running the PIC at 3.0v (with two 1.5v batteries).
But you have the Brownout fuse enabled. The brownout voltage for
this PIC is approximately 4.0v. Therefore, the PIC will be held in
a constant state of reset. It will never run. If you're running at 3v,
then change the fuse to NOBROWNOUT.
2nd thing: You have both the INTRC_IO and the HS fuses enabled.
These are in conflict. The compiler will use the last one that it sees,
which in this case is HS. That mode requires an external crystal or
oscillator. If you want INTRC_IO, then delete the HS fuse. |
|
|
jweller
Joined: 16 Oct 2006 Posts: 7
|
|
Posted: Fri Feb 23, 2007 3:05 pm |
|
|
Ok I changed it to NOBROWNOUT and deleted the HS fuse and still no luck. |
|
|
Ttelmah Guest
|
|
Posted: Fri Feb 23, 2007 3:40 pm |
|
|
Try adding the fuse 'CCPB3'. Otherwise the CCP1 output, may be routing to B0, and preventing the code from working.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 23, 2007 4:00 pm |
|
|
I tested the following program at both +5v and +3.0v and it works.
It blinks an LED on pin B0. It was compiled with vs. 3.249.
If it doesn't work for you, then I suspect you may be missing the
pull-up resistor on the MCLR pin or some other hardware problem.
Code: |
#include <16F88.H>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
void main()
{
// Blink an LED.
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
jweller
Joined: 16 Oct 2006 Posts: 7
|
|
Posted: Sun Feb 25, 2007 11:09 am |
|
|
PCM programmer wrote: | I suspect you may be missing the
pull-up resistor on the MCLR pin |
I'm not at work so I can't verify it right now, but I know your suspicions are dead on the money. I forgot the pullup.
this is what happens when they let software guys work with hardware |
|
|
jweller
Joined: 16 Oct 2006 Posts: 7
|
|
Posted: Mon Feb 26, 2007 12:04 pm |
|
|
Ok I added the pullup and my code still did not work. I am however able to compile and run your example code. Now that I've got something working, I can move forward. Thanks |
|
|
|