18F1220 once again...

Started by tadaosystems April 20, 2004
I'm just having difficulties getting an 18F1220 to run a simple
program.

I'm using HT PICC18 with an ICD 2.

My configuration bits:

__CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
RA6 digital i/o
__CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset 4.2 volts,
power-up timer, disable wdt
__CONFIG(3, MCLREN); // enable mclr
__CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
__CONFIG(5, UNPROTECT); // code
protection
__CONFIG(6, WRTEN);
__CONFIG(7, TRU);

And the very simple code:

void main(void)
{
PORTB = 0x00;
TRISB = 0x00;

while(1) {
RB0 = !RB0;
delay(10000);
}
}

void delay(unsigned int count)
{
while(count--)
;
return;
}

RB0 just has a single LED on it. When I run this, the LED lights up,
but doesn't flash. I've tried using timers too (with the proper
initialization and setup), but to no avail. It seems like the PIC
just runs through the while loop once and breaks out.

Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving the
chip 5 volts.

For awhile I thought it was the internal osc. Is RCIO the correct
osc setting? The data sheet shows INTIO2 as the internal osc, but
there is no corresponding entry in the pic18f1220.h header:

#define CONFIG1 0x300000
#define IESOEN 0xFFFF // Internal/External switch over mode
enabled
#define IESODIS 0x7FFF // Internal/External switch over mode
disabled
#define FCMEN 0xFFFF // Fail-safe clock monitor enabled
#define FCMDIS 0xBFFF // Fail-safe clock monitor disabled
#define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
#define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
#define RCIO 0xF8FF // Internal RC, RA6=IO
#define EXTIO 0xF7FF // External RC, RA6=IO
#define HSPLL 0xF6FF // HS with PLL enabled
#define ECIO 0xF5FF // EC, RA6=IO
#define ECCLKO 0xF4FF // EC, RA6=CLKOUT
#define HS 0xF2FF // HS osc
#define XT 0xF1FF // XT osc
#define LP 0xF0FF // LP osc

I just want to see a blinking LED, that's all I ask!




There may be other reasons the circuit won't work, but a 47K pull-up on
MCLR is way too high a value. 4.7K is OK, anything much higher makes
the chip susceptable to noise.

Charles Linquist ----- Original Message -----
From: "tadaosystems" <>
To: <>
Sent: Tuesday, April 20, 2004 11:21 AM
Subject: [piclist] 18F1220 once again... > I'm just having difficulties getting an 18F1220 to run a simple
> program.
>
> I'm using HT PICC18 with an ICD 2.
>
> My configuration bits:
>
> __CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
> RA6 digital i/o
> __CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset 4.2 volts,
> power-up timer, disable wdt
> __CONFIG(3, MCLREN); // enable mclr
> __CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
> __CONFIG(5, UNPROTECT); // code
> protection
> __CONFIG(6, WRTEN);
> __CONFIG(7, TRU);
>
> And the very simple code:
>
> void main(void)
> {
> PORTB = 0x00;
> TRISB = 0x00;
>
> while(1) {
> RB0 = !RB0;
> delay(10000);
> }
> }
>
> void delay(unsigned int count)
> {
> while(count--)
> ;
> return;
> }
>
> RB0 just has a single LED on it. When I run this, the LED lights up,
> but doesn't flash. I've tried using timers too (with the proper
> initialization and setup), but to no avail. It seems like the PIC
> just runs through the while loop once and breaks out.
>
> Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving the
> chip 5 volts.
>
> For awhile I thought it was the internal osc. Is RCIO the correct
> osc setting? The data sheet shows INTIO2 as the internal osc, but
> there is no corresponding entry in the pic18f1220.h header:
>
> #define CONFIG1 0x300000
> #define IESOEN 0xFFFF // Internal/External switch over mode
> enabled
> #define IESODIS 0x7FFF // Internal/External switch over mode
> disabled
> #define FCMEN 0xFFFF // Fail-safe clock monitor enabled
> #define FCMDIS 0xBFFF // Fail-safe clock monitor disabled
> #define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
> #define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
> #define RCIO 0xF8FF // Internal RC, RA6=IO
> #define EXTIO 0xF7FF // External RC, RA6=IO
> #define HSPLL 0xF6FF // HS with PLL enabled
> #define ECIO 0xF5FF // EC, RA6=IO
> #define ECCLKO 0xF4FF // EC, RA6=CLKOUT
> #define HS 0xF2FF // HS osc
> #define XT 0xF1FF // XT osc
> #define LP 0xF0FF // LP osc
>
> I just want to see a blinking LED, that's all I ask! > to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
> Yahoo! Groups Links >



I am using a 4.7K, it was just a typo. Thanks for the suggestion
though!

--- In , "Charles Linquist" <Charles@L...>
wrote:
>
> There may be other reasons the circuit won't work, but a 47K pull-
up on
> MCLR is way too high a value. 4.7K is OK, anything much higher
makes
> the chip susceptable to noise.
>
> Charles Linquist > ----- Original Message -----
> From: "tadaosystems" <flipflops67@h...>
> To: <>
> Sent: Tuesday, April 20, 2004 11:21 AM
> Subject: [piclist] 18F1220 once again... > > I'm just having difficulties getting an 18F1220 to run a simple
> > program.
> >
> > I'm using HT PICC18 with an ICD 2.
> >
> > My configuration bits:
> >
> > __CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
> > RA6 digital i/o
> > __CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset 4.2
volts,
> > power-up timer, disable wdt
> > __CONFIG(3, MCLREN); // enable mclr
> > __CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
> > __CONFIG(5, UNPROTECT); // code
> > protection
> > __CONFIG(6, WRTEN);
> > __CONFIG(7, TRU);
> >
> > And the very simple code:
> >
> > void main(void)
> > {
> > PORTB = 0x00;
> > TRISB = 0x00;
> >
> > while(1) {
> > RB0 = !RB0;
> > delay(10000);
> > }
> > }
> >
> > void delay(unsigned int count)
> > {
> > while(count--)
> > ;
> > return;
> > }
> >
> > RB0 just has a single LED on it. When I run this, the LED lights
up,
> > but doesn't flash. I've tried using timers too (with the proper
> > initialization and setup), but to no avail. It seems like the PIC
> > just runs through the while loop once and breaks out.
> >
> > Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving
the
> > chip 5 volts.
> >
> > For awhile I thought it was the internal osc. Is RCIO the correct
> > osc setting? The data sheet shows INTIO2 as the internal osc, but
> > there is no corresponding entry in the pic18f1220.h header:
> >
> > #define CONFIG1 0x300000
> > #define IESOEN 0xFFFF // Internal/External switch over mode
> > enabled
> > #define IESODIS 0x7FFF // Internal/External switch over mode
> > disabled
> > #define FCMEN 0xFFFF // Fail-safe clock monitor enabled
> > #define FCMDIS 0xBFFF // Fail-safe clock monitor disabled
> > #define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
> > #define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
> > #define RCIO 0xF8FF // Internal RC, RA6=IO
> > #define EXTIO 0xF7FF // External RC, RA6=IO
> > #define HSPLL 0xF6FF // HS with PLL enabled
> > #define ECIO 0xF5FF // EC, RA6=IO
> > #define ECCLKO 0xF4FF // EC, RA6=CLKOUT
> > #define HS 0xF2FF // HS osc
> > #define XT 0xF1FF // XT osc
> > #define LP 0xF0FF // LP osc
> >
> > I just want to see a blinking LED, that's all I ask!
> >
> >
> >
> >
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >




> 4.7K is OK, anything much higher makes the chip susceptable to noise.
Hmmm.  I've always used a 10k on MCLR.  Is that really too high?
----- Original Message -----
From: tadaosystems
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 1:47 PM
Subject: [piclist] Re: 18F1220 once again...

I am using a 4.7K, it was just a typo.  Thanks for the suggestion
though!

--- In p...@yahoogroups.com, "Charles Linquist" <Charles@L...>
wrote:
>
> There may be other reasons the circuit won't work, but a 47K pull-
up on
> MCLR is way too high a value.  4.7K is OK, anything much higher
makes
> the chip susceptable to noise.
>
> Charles Linquist> ----- Original Message -----
> From: "tadaosystems" <flipflops67@h...>
> To: <p...@yahoogroups.com>
> Sent: Tuesday, April 20, 2004 11:21 AM
> Subject: [piclist] 18F1220 once again...> > I'm just having difficulties getting an 18F1220 to run a simple
> > program.
> >
> > I'm using HT PICC18 with an ICD 2.
> >
> > My configuration bits:
> >
> > __CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
> > RA6 digital i/o
> > __CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset 4.2
volts,
> > power-up timer, disable wdt
> > __CONFIG(3, MCLREN); // enable mclr
> > __CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
> > __CONFIG(5, UNPROTECT); // code
> > protection
> > __CONFIG(6, WRTEN);
> > __CONFIG(7, TRU);
> >
> > And the very simple code:
> >
> > void main(void)
> > {
> > PORTB = 0x00;
> > TRISB = 0x00;
> >
> > while(1) {
> > RB0 = !RB0;
> > delay(10000);
> > }
> > }
> >
> > void delay(unsigned int count)
> > {
> > while(count--)
> > ;
> > return;
> > }
> >
> > RB0 just has a single LED on it.  When I run this, the LED lights
up,
> > but doesn't flash.  I've tried using timers too (with the proper
> > initialization and setup), but to no avail.  It seems like the PIC
> > just runs through the while loop once and breaks out.
> >
> > Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving
the
> > chip 5 volts.
> >
> > For awhile I thought it was the internal osc.  Is RCIO the correct
> > osc setting?  The data sheet shows INTIO2 as the internal osc, but
> > there is no corresponding entry in the pic18f1220.h header:
> >
> > #define CONFIG1 0x300000
> >  #define IESOEN 0xFFFF // Internal/External switch over mode
> > enabled
> >  #define IESODIS 0x7FFF // Internal/External switch over mode
> > disabled
> >  #define FCMEN 0xFFFF // Fail-safe clock monitor enabled
> >  #define FCMDIS 0xBFFF // Fail-safe clock monitor disabled
> >  #define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
> >  #define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
> >  #define RCIO 0xF8FF // Internal RC, RA6=IO
> >  #define EXTIO 0xF7FF // External RC, RA6=IO
> >  #define HSPLL 0xF6FF // HS with PLL enabled
> >  #define ECIO 0xF5FF // EC, RA6=IO
> >  #define ECCLKO 0xF4FF // EC, RA6=CLKOUT
> >  #define HS 0xF2FF // HS osc
> >  #define XT 0xF1FF // XT osc
> >  #define LP 0xF0FF // LP osc
> >
> > I just want to see a blinking LED, that's all I ask!
> >
> >
> >
> >
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

It depends on trace length and the noise level near the circuit.  I had an application where the chip would
spontaneously reboot.  I was using a 10K pull-up.  Changing to 4.7K solved the problem.  Since then, I
have designed at least 15 different boards using PICs.  All use 4.7K, none have had problems with spontaneous
RESETs.
 
Charles Linquist
 
 
 
 
----- Original Message -----
From: Bert Drake
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 12:25 PM
Subject: Re: [piclist] Re: 18F1220 once again...

> 4.7K is OK, anything much higher makes the chip susceptable to noise.
Hmmm.  I've always used a 10k on MCLR.  Is that really too high?
----- Original Message -----
From: tadaosystems
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 1:47 PM
Subject: [piclist] Re: 18F1220 once again...

I am using a 4.7K, it was just a typo.  Thanks for the suggestion
though!

--- In p...@yahoogroups.com, "Charles Linquist" <Charles@L...>
wrote:
>
> There may be other reasons the circuit won't work, but a 47K pull-
up on
> MCLR is way too high a value.  4.7K is OK, anything much higher
makes
> the chip susceptable to noise.
>
> Charles Linquist> ----- Original Message -----
> From: "tadaosystems" <flipflops67@h...>
> To: <p...@yahoogroups.com>
> Sent: Tuesday, April 20, 2004 11:21 AM
> Subject: [piclist] 18F1220 once again...> > I'm just having difficulties getting an 18F1220 to run a simple
> > program.
> >
> > I'm using HT PICC18 with an ICD 2.
> >
> > My configuration bits:
> >
> > __CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
> > RA6 digital i/o
> > __CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset 4.2
volts,
> > power-up timer, disable wdt
> > __CONFIG(3, MCLREN); // enable mclr
> > __CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
> > __CONFIG(5, UNPROTECT); // code
> > protection
> > __CONFIG(6, WRTEN);
> > __CONFIG(7, TRU);
> >
> > And the very simple code:
> >
> > void main(void)
> > {
> > PORTB = 0x00;
> > TRISB = 0x00;
> >
> > while(1) {
> > RB0 = !RB0;
> > delay(10000);
> > }
> > }
> >
> > void delay(unsigned int count)
> > {
> > while(count--)
> > ;
> > return;
> > }
> >
> > RB0 just has a single LED on it.  When I run this, the LED lights
up,
> > but doesn't flash.  I've tried using timers too (with the proper
> > initialization and setup), but to no avail.  It seems like the PIC
> > just runs through the while loop once and breaks out.
> >
> > Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving
the
> > chip 5 volts.
> >
> > For awhile I thought it was the internal osc.  Is RCIO the correct
> > osc setting?  The data sheet shows INTIO2 as the internal osc, but
> > there is no corresponding entry in the pic18f1220.h header:
> >
> > #define CONFIG1 0x300000
> >  #define IESOEN 0xFFFF // Internal/External switch over mode
> > enabled
> >  #define IESODIS 0x7FFF // Internal/External switch over mode
> > disabled
> >  #define FCMEN 0xFFFF // Fail-safe clock monitor enabled
> >  #define FCMDIS 0xBFFF // Fail-safe clock monitor disabled
> >  #define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
> >  #define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
> >  #define RCIO 0xF8FF // Internal RC, RA6=IO
> >  #define EXTIO 0xF7FF // External RC, RA6=IO
> >  #define HSPLL 0xF6FF // HS with PLL enabled
> >  #define ECIO 0xF5FF // EC, RA6=IO
> >  #define ECCLKO 0xF4FF // EC, RA6=CLKOUT
> >  #define HS 0xF2FF // HS osc
> >  #define XT 0xF1FF // XT osc
> >  #define LP 0xF0FF // LP osc
> >
> > I just want to see a blinking LED, that's all I ask!
> >
> >
> >
> >
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions



I tend to sprinkle a generous helping of filter caps all over the board.  (Specifically near MCLR and the power pins.)
Maybe thats why I've not had the problem.  I've really only done half a dozen or so PIC projects, though.
 
Perhaps I'll try a 4.7 next time.  Does it work ok with most ICSP programmers?
----- Original Message -----
From: Charles Linquist
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 2:58 PM
Subject: Re: [piclist] Re: 18F1220 once again...

It depends on trace length and the noise level near the circuit.  I had an application where the chip would
spontaneously reboot.  I was using a 10K pull-up.  Changing to 4.7K solved the problem.  Since then, I
have designed at least 15 different boards using PICs.  All use 4.7K, none have had problems with spontaneous
RESETs.
 
Charles Linquist
 


I use a Picstart Plus (with "extender cables") and an ICD2.  Both work reliably using 4.7K pullup resistors on MCLR.
 
Charles Linquist
 
----- Original Message -----
From: Bert Drake
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 1:22 PM
Subject: Re: [piclist] Re: 18F1220 once again...

I tend to sprinkle a generous helping of filter caps all over the board.  (Specifically near MCLR and the power pins.)
Maybe thats why I've not had the problem.  I've really only done half a dozen or so PIC projects, though.
 
Perhaps I'll try a 4.7 next time.  Does it work ok with most ICSP programmers?
----- Original Message -----
From: Charles Linquist
To: p...@yahoogroups.com
Sent: Tuesday, April 20, 2004 2:58 PM
Subject: Re: [piclist] Re: 18F1220 once again...

It depends on trace length and the noise level near the circuit.  I had an application where the chip would
spontaneously reboot.  I was using a 10K pull-up.  Changing to 4.7K solved the problem.  Since then, I
have designed at least 15 different boards using PICs.  All use 4.7K, none have had problems with spontaneous
RESETs.
 
Charles Linquist
 


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
At 01:25 PM 4/20/2004, Bert Drake wrote:
> > 4.7K is OK, anything much higher makes the chip susceptable to noise.
>Hmmm. I've always used a 10k on MCLR. Is that really too high?

Naw - Microchip states that 39K is the largest acceptable value (mid-range
reference manual). I use 10k or 4k7 for most of my projects.

dwayne --
Dwayne Reid <>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.



Alright, I know for sure the internal oscillator works, and the
timers do, because when I use this:

void main(void)
{
PORTB = 0x00;
TRISB = 0x00;
IRCF2 = 1;
IRCF1 = 1;
IRCF0 = 1;
SCS1 = 0;
SCS0 = 0;
T1CON = 0b00111100; // Timer1 set up = off
TMR1ON = 1;
TMR1IE = 1;
TMR1IF = 0;
TMR1 = 0;
while(1) {
if (TMR1IF) {
TMR1IF = 0;
RB0 = !RB0;

}
}
}

...the LED starts out off, since we set PORTB to 0, and then after
about 1/4 of a second, the LED will light up. After that though,
nothing ever happens again, and it should keep blinking.

It's like the while loop is not repeated.

Blink darnit!
--- In , "tadaosystems" <flipflops67@h...>
wrote:
> I'm just having difficulties getting an 18F1220 to run a simple
> program.
>
> I'm using HT PICC18 with an ICD 2.
>
> My configuration bits:
>
> __CONFIG(1, RCIO & IESOEN & FCMDIS); // internal oscillator with
> RA6 digital i/o
> __CONFIG(2, BORV42 & PWRTEN & WDTDIS); // brown out reset
4.2 volts,
> power-up timer, disable wdt
> __CONFIG(3, MCLREN); // enable mclr
> __CONFIG(4, LVPDIS & DEBUGDIS);// disable lvp mode
> __CONFIG(5, UNPROTECT); //
code
> protection
> __CONFIG(6, WRTEN);
> __CONFIG(7, TRU);
>
> And the very simple code:
>
> void main(void)
> {
> PORTB = 0x00;
> TRISB = 0x00;
>
> while(1) {
> RB0 = !RB0;
> delay(10000);
> }
> }
>
> void delay(unsigned int count)
> {
> while(count--)
> ;
> return;
> }
>
> RB0 just has a single LED on it. When I run this, the LED lights
up,
> but doesn't flash. I've tried using timers too (with the proper
> initialization and setup), but to no avail. It seems like the PIC
> just runs through the while loop once and breaks out.
>
> Of course I'm tying MCLR to Vdd with a 47K ohm resistor, giving the
> chip 5 volts.
>
> For awhile I thought it was the internal osc. Is RCIO the correct
> osc setting? The data sheet shows INTIO2 as the internal osc, but
> there is no corresponding entry in the pic18f1220.h header:
>
> #define CONFIG1 0x300000
> #define IESOEN 0xFFFF // Internal/External switch
over mode
> enabled
> #define IESODIS 0x7FFF // Internal/External switch over mode
> disabled
> #define FCMEN 0xFFFF // Fail-safe clock monitor
enabled
> #define FCMDIS 0xBFFF // Fail-safe clock monitor
disabled
> #define EXTCLKO 0xFFFF // External RC, RA6=CLKOUT
> #define RCCLKO 0xF9FF // Internal RC, RA6=CLKOUT
> #define RCIO 0xF8FF // Internal RC, RA6=IO
> #define EXTIO 0xF7FF // External RC, RA6=IO
> #define HSPLL 0xF6FF // HS with PLL enabled
> #define ECIO 0xF5FF // EC, RA6=IO
> #define ECCLKO 0xF4FF // EC, RA6=CLKOUT
> #define HS 0xF2FF // HS osc
> #define XT 0xF1FF // XT osc
> #define LP 0xF0FF // LP osc
>
> I just want to see a blinking LED, that's all I ask!





I've never programed in C on PICs so I can't speak from authority on
PIC flavors of C but technically speaking "RB0 = !RB0" is not what
you want to do. What you want to do is "RB0 = ~RB0". No guarantee
but this just *might* do it... (The answer lies in the generated asm
code.)

--Scott

--- In , "tadaosystems" <flipflops67@h...>
wrote:
> Alright, I know for sure the internal oscillator works, and the
> timers do, because when I use this:
>
> void main(void)
> {
> PORTB = 0x00;
> TRISB = 0x00;
> IRCF2 = 1;
> IRCF1 = 1;
> IRCF0 = 1;
> SCS1 = 0;
> SCS0 = 0;
> T1CON = 0b00111100; // Timer1 set up = off
> TMR1ON = 1;
> TMR1IE = 1;
> TMR1IF = 0;
> TMR1 = 0;
> while(1) {
> if (TMR1IF) {
> TMR1IF = 0;
> RB0 = !RB0;
>
> }
> }
> }
>
> ...the LED starts out off, since we set PORTB to 0, and then after
> about 1/4 of a second, the LED will light up. After that though,
> nothing ever happens again, and it should keep blinking.
>
> It's like the while loop is not repeated.
>
> Blink darnit!