A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
16F818 and the dodgy oscillator - Staiger - Apr 17 11:20:11 2008
Colleagues,
I'm trying to use the 16F818 for the first time (prior to this I've
used the 16F84 and the 12F509).
I want to use the internal oscillator, and I'm having a heck of a time
getting the chip to operate reliably. I've got it set up so that
OSCCON sets the clock to 4MHz, and CLK_OUT goes to RA6, so I can see
what is going on with my oscilloscope.
The problem is that the chip seems to power up randomly into one of
three states:
1/ It produces a 1MHz square wave on RA6, and my program runs fine (a
simple LED flasher)
2/ It produces a 7690Hz square wave on RA6 (i.e. a period of 130us),
and the LED doesn't flash
3/ RA6 sits at 0V, and the LED doesn't flash
By switching the power on and off I can usually get it to change
between these states, but with no control over what happens. Obviously
only 1/ above is correct!
I've tried every combination of settings in the CONFIG bits that seem
relevant, and am now at my wit's end.
FYI, I'm programming it in SourceBoost 'C', hosted in MPLAB, with a
Picstart Plus programmer (fully updated). This set up works perfectly
with the 16F84 and 12F509 chips, so I'm pretty confident the
programming environment is OK.
Finally, I've tried setting the CONFIG bits in code, and using the
Configure | Configuration bits... menu option in MPLAB, but it makes no
difference.
Below is the software listing. It doesn't seem possible to make it any
simpler!
Any assistance would be VERY MUCH appreciated!
Steve
------------------------
//try to get the damn 16F818 working
#include
#pragma DATA _CONFIG, _BODEN_OFF & _MCLR_OFF & _PWRTE_ON &
_INTRC_CLKOUT & _WDT_OFF
#pragma CLOCK_FREQ 4000000
void main(void)
{
adcon1 = 0b00000110;
option_reg = 0b00000000;
intcon = 0b00000000;
pie1 = 0b00000000;
pie2 = 0b00000000;
trisa = 0b00000000;
trisb = 0b00000000;
osccon = 0b01100000;
while(1)
{
portb = 0b11111111;
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
portb = 0b00000000;
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
}
}
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: 16F818 and the dodgy oscillator - Dennis Clark - Apr 17 12:35:45 2008
What have you done with the reset line? You should be pulling /MCLR up
with a 10K resistor.
DLC
> Colleagues,
>
> I'm trying to use the 16F818 for the first time (prior to this I've
> used the 16F84 and the 12F509).
>
> I want to use the internal oscillator, and I'm having a heck of a time
> getting the chip to operate reliably. I've got it set up so that
> OSCCON sets the clock to 4MHz, and CLK_OUT goes to RA6, so I can see
> what is going on with my oscilloscope.
>
> The problem is that the chip seems to power up randomly into one of
> three states:
>
> 1/ It produces a 1MHz square wave on RA6, and my program runs fine (a
> simple LED flasher)
>
> 2/ It produces a 7690Hz square wave on RA6 (i.e. a period of 130us),
> and the LED doesn't flash
>
> 3/ RA6 sits at 0V, and the LED doesn't flash
>
> By switching the power on and off I can usually get it to change
> between these states, but with no control over what happens. Obviously
> only 1/ above is correct!
>
> I've tried every combination of settings in the CONFIG bits that seem
> relevant, and am now at my wit's end.
>
> FYI, I'm programming it in SourceBoost 'C', hosted in MPLAB, with a
> Picstart Plus programmer (fully updated). This set up works perfectly
> with the 16F84 and 12F509 chips, so I'm pretty confident the
> programming environment is OK.
>
> Finally, I've tried setting the CONFIG bits in code, and using the
> Configure | Configuration bits... menu option in MPLAB, but it makes no
> difference.
>
> Below is the software listing. It doesn't seem possible to make it any
> simpler!
>
> Any assistance would be VERY MUCH appreciated!
>
> Steve
>
> ------------------------
>
> //try to get the damn 16F818 working
>
> #include
> #pragma DATA _CONFIG, _BODEN_OFF & _MCLR_OFF & _PWRTE_ON &
> _INTRC_CLKOUT & _WDT_OFF
>
> #pragma CLOCK_FREQ 4000000
>
> void main(void)
> {
> adcon1 = 0b00000110;
> option_reg = 0b00000000;
> intcon = 0b00000000;
> pie1 = 0b00000000;
> pie2 = 0b00000000;
>
> trisa = 0b00000000;
> trisb = 0b00000000;
> osccon = 0b01100000;
> while(1)
> {
> portb = 0b11111111;
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> portb = 0b00000000;
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> delay_ms(100);
> }
> }
> ------------------------------------
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: [other] [Spam] 16F818 and the dodgy oscillator - Michael Heins - Apr 28 19:28:06 2008
Steve;
Sounds like a slow VDD power up issue possibly (since it is an internal osc
of the PIC). The internal osc may need time to stabilize. I don't use the
16f818, but it should have nMCLR signal same as all other PICS. Take a look
at the PIC18F2682/2685/4682/4685 datasheet on pg. 43 for a sample circuit
for holding nMCLR low for a while when using a slow Vdd startup. (figure
4-2)
Good luck
-mike
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf Of
Staiger
Sent: Sunday, March 09, 2008 9:11 AM
To: p...@yahoogroups.com
Subject: [other] [Spam] [piclist] 16F818 and the dodgy oscillator
Colleagues,
I'm trying to use the 16F818 for the first time (prior to this I've
used the 16F84 and the 12F509).
I want to use the internal oscillator, and I'm having a heck of a time
getting the chip to operate reliably. I've got it set up so that
OSCCON sets the clock to 4MHz, and CLK_OUT goes to RA6, so I can see
what is going on with my oscilloscope.
The problem is that the chip seems to power up randomly into one of
three states:
1/ It produces a 1MHz square wave on RA6, and my program runs fine (a
simple LED flasher)
2/ It produces a 7690Hz square wave on RA6 (i.e. a period of 130us),
and the LED doesn't flash
3/ RA6 sits at 0V, and the LED doesn't flash
By switching the power on and off I can usually get it to change
between these states, but with no control over what happens. Obviously
only 1/ above is correct!
I've tried every combination of settings in the CONFIG bits that seem
relevant, and am now at my wit's end.
FYI, I'm programming it in SourceBoost 'C', hosted in MPLAB, with a
Picstart Plus programmer (fully updated). This set up works perfectly
with the 16F84 and 12F509 chips, so I'm pretty confident the
programming environment is OK.
Finally, I've tried setting the CONFIG bits in code, and using the
Configure | Configuration bits... menu option in MPLAB, but it makes no
difference.
Below is the software listing. It doesn't seem possible to make it any
simpler!
Any assistance would be VERY MUCH appreciated!
Steve
------------------------
//try to get the damn 16F818 working
#include
#pragma DATA _CONFIG, _BODEN_OFF & _MCLR_OFF & _PWRTE_ON &
_INTRC_CLKOUT & _WDT_OFF
#pragma CLOCK_FREQ 4000000
void main(void)
{
adcon1 = 0b00000110;
option_reg = 0b00000000;
intcon = 0b00000000;
pie1 = 0b00000000;
pie2 = 0b00000000;
trisa = 0b00000000;
trisb = 0b00000000;
osccon = 0b01100000;
while(1)
{
portb = 0b11111111;
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
portb = 0b00000000;
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
}
}

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: 16F818 and the dodgy oscillator - Nelson Viegas - Apr 28 19:28:29 2008
I had the same problem when I was starting (not so long ago)! I pulled that
line up with a 4.7K res. and it worked happily ever after. BTW, any
significant diference between using a 4.7K ou 10K resistor?
Thanks!
Best regards,
Nelson
2008/4/17, Dennis Clark
:
>
> What have you done with the reset line? You should be pulling /MCLR up
> with a 10K resistor.
>
> DLC
>
> > Colleagues,
> >
> > I'm trying to use the 16F818 for the first time (prior to this I've
> > used the 16F84 and the 12F509).
> >
> > I want to use the internal oscillator, and I'm having a heck of a time
> > getting the chip to operate reliably. I've got it set up so that
> > OSCCON sets the clock to 4MHz, and CLK_OUT goes to RA6, so I can see
> > what is going on with my oscilloscope.
> >
> > The problem is that the chip seems to power up randomly into one of
> > three states:
> >
> > 1/ It produces a 1MHz square wave on RA6, and my program runs fine (a
> > simple LED flasher)
> >
> > 2/ It produces a 7690Hz square wave on RA6 (i.e. a period of 130us),
> > and the LED doesn't flash
> >
> > 3/ RA6 sits at 0V, and the LED doesn't flash
> >
> > By switching the power on and off I can usually get it to change
> > between these states, but with no control over what happens. Obviously
> > only 1/ above is correct!
> >
> > I've tried every combination of settings in the CONFIG bits that seem
> > relevant, and am now at my wit's end.
> >
> > FYI, I'm programming it in SourceBoost 'C', hosted in MPLAB, with a
> > Picstart Plus programmer (fully updated). This set up works perfectly
> > with the 16F84 and 12F509 chips, so I'm pretty confident the
> > programming environment is OK.
> >
> > Finally, I've tried setting the CONFIG bits in code, and using the
> > Configure | Configuration bits... menu option in MPLAB, but it makes no
> > difference.
> >
> > Below is the software listing. It doesn't seem possible to make it any
> > simpler!
> >
> > Any assistance would be VERY MUCH appreciated!
> >
> > Steve
> >
> > ------------------------
> >
> > //try to get the damn 16F818 working
> >
> > #include
> > #pragma DATA _CONFIG, _BODEN_OFF & _MCLR_OFF & _PWRTE_ON &
> > _INTRC_CLKOUT & _WDT_OFF
> >
> > #pragma CLOCK_FREQ 4000000
> >
> > void main(void)
> > {
> > adcon1 = 0b00000110;
> > option_reg = 0b00000000;
> > intcon = 0b00000000;
> > pie1 = 0b00000000;
> > pie2 = 0b00000000;
> >
> > trisa = 0b00000000;
> > trisb = 0b00000000;
> > osccon = 0b01100000;
> >
> >
> > while(1)
> > {
> > portb = 0b11111111;
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > portb = 0b00000000;
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > delay_ms(100);
> > }
> >
> >
> > }
> >
> >
> > ------------------------------------
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > instructionsYahoo! Groups Links
> >
> >
> >
> > --
> Dennis Clark
> TTT Enterprises
>

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: 16F818 and the dodgy oscillator - "John J. McDonough, WB8RCR" - Apr 28 20:17:09 2008
----- Original Message -----
From: "Staiger"
To:
Sent: Sunday, March 09, 2008 9:11 AM
Subject: [piclist] 16F818 and the dodgy oscillator
> Colleagues,
>
> I'm trying to use the 16F818 for the first time (prior to this I've
> used the 16F84 and the 12F509).
Be sure that RB3 is pulled LOW during startup. Also, you should have
specified _LVP_OFF in your config bits
72/73 de WB8RCR http://www.qsl.net/wb8rcr
didileydadidah QRP-L #1446 Code Warriors #35
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )