Searching \ for '[PIC] Blink LED for solarwind' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/displays.htm?key=led
Search entire site for: 'Blink LED for solarwind'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Blink LED for solarwind'
2008\12\17@125814 by Bob Blick

face
flavicon
face
Here's a program that you can test. I was unable to duplicate the same
conditions you have - the closest part I had to a 16F886 that was in DIP
package was a 16F884 so I used that.

Also I used version 8.05pl2 of the HiTech compiler but the reason for
that would need to be in a different thread.

The command line I used to compile was:
picc -16F884 -Zg9 -O blink.c

Tie MCLR high, hook an LED through a 1k resistor to RC4, apply power and
it should blink about once per second.

Give it a try and see if it works for you.

Cheerful regards,

Bob

#include <pic.h>
__CONFIG(UNPROTECT & WDTDIS & LVPDIS & BOREN & PWRTEN & INTIO &
MCLRDIS);
__CONFIG(BORV21);

void main(){
 unsigned int i = 0;
 PORTA = 0;
 PORTB = 0;
 PORTC = 0;
 PORTD = 0;
 PORTE = 0;
 TRISA = 0;  // no inputs
 TRISB = 0;
 TRISC = 0;
 TRISD = 0;
 TRISE = 0;
 ANSEL  = 0; // no analog
 ANSELH = 0;

 while(1){
   if(!--i){
     if (RC4){
       RC4 = 0;
     } else {
       RC4 = 1;
     }
   }
 }
}


--
http://www.fastmail.fm - mmm... Fastmail...

2008\12\17@132628 by Vitaliy

flavicon
face
"Bob Blick"  wrote:
{Quote hidden}

Why "about once per second"? I don't see the clock specified anywhere.


2008\12\17@135134 by Bryon.Sol

flavicon
face
Funny - I was going to ask the same thing, but since I'm a
lurking/learning newbie I thought I just missed something.

Where IS the clock set?

Bryon



"Vitaliy" <spam_OUTspamTakeThisOuTspammaksimov.org>
Sent by: .....piclist-bouncesKILLspamspam@spam@mit.edu
12/17/2008 01:24 PM
Please respond to
"Microcontroller discussion list - Public." <piclistspamKILLspammit.edu>


To
"Microcontroller discussion list - Public." <.....piclistKILLspamspam.....mit.edu>
cc

Subject
Re: [PIC] Blink LED for solarwind






"Bob Blick"  wrote:
{Quote hidden}

Why "about once per second"? I don't see the clock specified anywhere.


2008\12\17@140717 by Bob Blick

face
flavicon
face

On Wed, 17 Dec 2008 11:24:40 -0700, "Vitaliy" <EraseMEspamspam_OUTspamTakeThisOuTmaksimov.org> said:

>
> Why "about once per second"? I don't see the clock specified anywhere.

Default clock is 4MHz, so that's 1 cycle per microsecond, and an
"if(!--i)" loop with i as an integer takes probably 12 cycles. So "about
1 second" is more like "about .768432 second"

Cheers,

Bob

--
http://www.fastmail.fm - Choose from over 50 domains or use your own

2008\12\17@141002 by Jan-Erik Soderholm

face picon face
> Where IS the clock set?

 if(!--i)

I'd guess...

2008\12\17@141855 by M.L.

flavicon
face
It looks to me like it uses the internal oscillator

INTIO = use internal osc, I/o on osc pins - at least on 18F parts that
I'm familiar with

-
ML

On Wed, Dec 17, 2008 at 1:51 PM,  <Bryon.Solspamspam_OUTus.interplex.com> wrote:
{Quote hidden}

> -

2008\12\17@142509 by Bob Blick

face
flavicon
face

On Wed, 17 Dec 2008 11:06:52 -0800, "Bob Blick" <TakeThisOuTbobblickEraseMEspamspam_OUTftml.net>
said:
>
> On Wed, 17 Dec 2008 11:24:40 -0700, "Vitaliy" <RemoveMEspamspamTakeThisOuTmaksimov.org> said:
>
> >
> > Why "about once per second"? I don't see the clock specified anywhere.
>
> Default clock is 4MHz, so that's 1 cycle per microsecond, and an
> "if(!--i)" loop with i as an integer takes probably 12 cycles. So "about
> 1 second" is more like "about .768432 second"


Sorry, I really didn't explain that very well. "if(!--i)" takes 65536
passes each time to be true, and then the LED toggle takes place. Since
the decrementing of i, testing, and looping of main takes about 12
cycles, it takes 65536 * 12 cycles between each toggling of the LED.

-Bob

--
http://www.fastmail.fm - Access all of your messages and folders
                         wherever you are

2008\12\17@143453 by Bob Blick

face
flavicon
face

On Wed, 17 Dec 2008 11:24:40 -0700, "Vitaliy" <spamEraseMEspam.....maksimov.org> said:

> Why "about once per second"? I don't see the clock specified anywhere.

You caught me off guard, "clock" is a little quaint for me, but if you
meant oscillator, in HiTech you specify the type of oscillator in the
__CONFIG line. And the default is 4MHz on that part for the internal
oscillator. To select a different frequency you would set the
appropriate registers for the prescaler or to choose the normal/LF
internal oscillator.

You must use CCS, which has macros and is different. HiTech tends to be
a little stripped down.

Cheerful regards,

Bob

--
http://www.fastmail.fm - mmm... Fastmail...

2008\12\17@144537 by Vitaliy

flavicon
face
Bob Blick wrote:
>> Why "about once per second"? I don't see the clock specified anywhere.
>
> Default clock is 4MHz, so that's 1 cycle per microsecond, and an
> "if(!--i)" loop with i as an integer takes probably 12 cycles. So "about
> 1 second" is more like "about .768432 second"

Thanks for the explanation!

The part that confused me is that I did not expect "int" to be 16 bits long.

Vitaliy

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...