PIC 16F1827 not running

Started by Andrew April 14, 2011
Hi,

I am working on a project using a PIC 16F1827, using it's internal oscillator running at 8MHz. I can download firmware into the micro and verify that the code has successfully been programmed. However the code does not appear to be running. I have verified this by writing code to toggle a pin and have viewed this pin on an oscilloscope. I have pasted my code below. Could someone enlighten me as to what I may be doing wrong.

I am using the CCS PCM C compiler from MPLAB 8.63.

Thanks in advance

Andrew Ellis

// main.c
// Set up the processor

#include <16F1827.h>
#fuses INTRC_IO,PLL,PUT,BROWNOUT,NOMCLR
#fuses NOIESO,NOFCMEN,NOCLKOUT,NOLVP,NODEBUG,BORV25,NOSTVREN

#use delay(clock00000)

void main()
{
setup_oscillator(OSC_8MHZ | OSC_INTRC | OSC_PLL_ON);
// Setup port B; 0 - output, 1 - input
set_tris_b(0xC6);

while (1)
{
output_bit(PIN_B3, ~input(PIN_B3));
}
}

> Hi,
>
> I am working on a project using a PIC 16F1827, using it's internal
> oscillator running at 8MHz. I can download firmware into the micro and
> verify that the code has successfully been programmed. However the code
> does not appear to be running. I have verified this by writing code to
> toggle a pin and have viewed this pin on an oscilloscope. I have pasted my
> code below. Could someone enlighten me as to what I may be doing wrong.
>
> I am using the CCS PCM C compiler from MPLAB 8.63.
>
> Thanks in advance
>
> Andrew Ellis

How about setting the OSC2 pin as a clock out so you can see that the
clock is indeed running. Also (this is simple), make sure the reset line
is pulled high.

Good luck!

Harold
--
FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
opportunities available!
Hi Harold,

Thank you for your reply.

I have ensured that /MCLR is pulled high.

As suggested I have tried setting pin 15 as clkout but I'm not seeing anything on that pin.

Do you have any further ideas please?

Thanks

Andrew

--- In p..., "Harold Hallikainen" wrote:
> > Hi,
> >
> > I am working on a project using a PIC 16F1827, using it's internal
> > oscillator running at 8MHz. I can download firmware into the micro and
> > verify that the code has successfully been programmed. However the code
> > does not appear to be running. I have verified this by writing code to
> > toggle a pin and have viewed this pin on an oscilloscope. I have pasted my
> > code below. Could someone enlighten me as to what I may be doing wrong.
> >
> > I am using the CCS PCM C compiler from MPLAB 8.63.
> >
> > Thanks in advance
> >
> > Andrew Ellis
>
> How about setting the OSC2 pin as a clock out so you can see that the
> clock is indeed running. Also (this is simple), make sure the reset line
> is pulled high.
>
> Good luck!
>
> Harold
> --
> FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
> opportunities available!
>

Hi,
You need to have a 10K resistor from MCLR pin to Vdd and a small capacitor
to Gnd to provide a reset signal.
Do you have them in your circuit? Best regards
Noam

________________________________
From: Andrew
To: p...
Sent: Fri, April 15, 2011 11:16:13 AM
Subject: [piclist] Re: PIC 16F1827 not running

 
Hi Harold,

Thank you for your reply.

I have ensured that /MCLR is pulled high.

As suggested I have tried setting pin 15 as clkout but I'm not seeing anything
on that pin.

Do you have any further ideas please?

Thanks

Andrew

--- In p..., "Harold Hallikainen" wrote:
> > Hi,
> >
> > I am working on a project using a PIC 16F1827, using it's internal
> > oscillator running at 8MHz. I can download firmware into the micro and
> > verify that the code has successfully been programmed. However the code
> > does not appear to be running. I have verified this by writing code to
> > toggle a pin and have viewed this pin on an oscilloscope. I have pasted my
> > code below. Could someone enlighten me as to what I may be doing wrong.
> >
> > I am using the CCS PCM C compiler from MPLAB 8.63.
> >
> > Thanks in advance
> >
> > Andrew Ellis
>
> How about setting the OSC2 pin as a clock out so you can see that the
> clock is indeed running. Also (this is simple), make sure the reset line
> is pulled high.
>
> Good luck!
>
> Harold
> --
> FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
> opportunities available!
>
Andrew, it's been a while for me with CCS C but if you're using an ICD or PICkit, do you need a special line in your include file to indicate that? Also, assuming you're building for debug (look at options under the Project menu heading in MPLAB IDE), what happens when you try to Run with the debugger?

Coop, AA1WW
________________________________
> To: p...
> From: a...@yahoo.co.uk
> Date: Fri, 15 Apr 2011 09:16:13 +0000
> Subject: [piclist] Re: PIC 16F1827 not running
>
> Hi Harold,
>
> Thank you for your reply.
>
> I have ensured that /MCLR is pulled high.
>
> As suggested I have tried setting pin 15 as clkout but I'm not seeing
> anything on that pin.
>
> Do you have any further ideas please?
>
> Thanks
>
> Andrew
>
> --- In p..., "Harold
> Hallikainen" wrote:
> >
> >
> > > Hi,
> > >
> > > I am working on a project using a PIC 16F1827, using it's internal
> > > oscillator running at 8MHz. I can download firmware into the micro and
> > > verify that the code has successfully been programmed. However the code
> > > does not appear to be running. I have verified this by writing code to
> > > toggle a pin and have viewed this pin on an oscilloscope. I have
> pasted my
> > > code below. Could someone enlighten me as to what I may be doing wrong.
> > >
> > > I am using the CCS PCM C compiler from MPLAB 8.63.
> > >
> > > Thanks in advance
> > >
> > > Andrew Ellis
> >
> > How about setting the OSC2 pin as a clock out so you can see that the
> > clock is indeed running. Also (this is simple), make sure the reset line
> > is pulled high.
> >
> > Good luck!
> >
> > Harold
> >
> >
> > --
> > FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
> > opportunities available!
> >
>

I seem to have resolved the issue; I tried changing the build from debug to release and the code works. I've not had a problem with that before.

Andrew

--- In p..., Jeff Cooper wrote:
> Andrew, it's been a while for me with CCS C but if you're using an ICD or PICkit, do you need a special line in your include file to indicate that? Also, assuming you're building for debug (look at options under the Project menu heading in MPLAB IDE), what happens when you try to Run with the debugger?
>
> Coop, AA1WW
> ________________________________
> > To: p...
> > From: ajellisuk@...
> > Date: Fri, 15 Apr 2011 09:16:13 +0000
> > Subject: [piclist] Re: PIC 16F1827 not running
> >
> >
> >
> > Hi Harold,
> >
> > Thank you for your reply.
> >
> > I have ensured that /MCLR is pulled high.
> >
> > As suggested I have tried setting pin 15 as clkout but I'm not seeing
> > anything on that pin.
> >
> > Do you have any further ideas please?
> >
> > Thanks
> >
> > Andrew
> >
> > --- In p..., "Harold
> > Hallikainen" wrote:
> > >
> > >
> > > > Hi,
> > > >
> > > > I am working on a project using a PIC 16F1827, using it's internal
> > > > oscillator running at 8MHz. I can download firmware into the micro and
> > > > verify that the code has successfully been programmed. However the code
> > > > does not appear to be running. I have verified this by writing code to
> > > > toggle a pin and have viewed this pin on an oscilloscope. I have
> > pasted my
> > > > code below. Could someone enlighten me as to what I may be doing wrong.
> > > >
> > > > I am using the CCS PCM C compiler from MPLAB 8.63.
> > > >
> > > > Thanks in advance
> > > >
> > > > Andrew Ellis
> > >
> > > How about setting the OSC2 pin as a clock out so you can see that the
> > > clock is indeed running. Also (this is simple), make sure the reset line
> > > is pulled high.
> > >
> > > Good luck!
> > >
> > > Harold
> > >
> > >
> > > --
> > > FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
> > > opportunities available!
> > >
> >
> >
>

> I seem to have resolved the issue; I tried changing the build from debug
> to release and the code works. I've not had a problem with that before.
>
> Andrew
Glad you solved it! I've found that a debug build will run with a
debugger, but not without. A release build will run on its own.

Harold

--
FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
opportunities available!
10k? Why that value? I've always used a 4k7 and never had a problem. Just wondering
Cheers
Gary